lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

It was thus said that the Great Chris Datfung once stated:
> On Tue, Oct 15, 2013 at 11:15 PM, Sean Conner <> wrote:
> >
> >         -- convert the table to an XML object
> >         doc =
> >         print(doc)
> >
> >
> Thanks, that did the trick. Normally when I try running print on a table I
> need to use ipairs() to print its contents. What is unique about the doc
> object (which is essentially a table in lua if I understand correctly) that
> allows you to use the print() function directly? Can I convert the doc
> object to a string and keep the formatting as well?

  There are metatables associated with each table in the doc object that
provide a __tostring method.  The print() function calls tostring() on any
paramters, so doing a 

	x = tostring(doc)

is the same as