lua-users home
lua-l archive

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


Luiz Henrique de Figueiredo wrote:

Has there been any standerd way of representing a XML document in a lua table structure defined yet?
<person id="1234">
<name>
  <first>John</first>
  <last>Smith</last>
</name>
</person>

I don't know anything about XML, but in Lua this info could be represented as

person{
 id="1234",
 {
  name={first="John", last="Smith"}
 }
}


Yes, thats the ideal lua way to do it, however XML documents don't always work that way and I'm after a generic solution :-(

For example:

<PARENT>
 <CHILD>Timmy</CHILD>
 <CHILD>Tommy</CHILD>
</PARENT>

Is valid XML, but, of course, this:

parent = {
 child = "Timmy",
 child = "Tommy"
}

Isn't valid lua, and is the reason I've knocked up what looks like a mess of a structure. But it seems to be the most flexable/sensible way to do it.

Basicly I was hoping somebody has already covered this and had some utils put up to work with it all. Looks like it might have to be me doing this if nobody else has already ;-P

Scott Morgan