lua-users home
lua-l archive

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


Jay Carlson wrote:

It would be nice to have some agreement here.  I don't promise that I'll
rewrite the internals of Lua XML-RPC to use this new format (hey, it's
working now with Roberto's expat binding) but a convention would be nice.

Meta: Python decides these issues by shipping things in the standard
distro.  Lua doesn't decide these things.  I don't know what's better.

Jay

I put this question up a while back (around July 2003), my solution, which I have been using in some poduction enviroments, was to handle it like the following:

<TEST foo="Hello" bar="world">Some <B color="Blue">Text</B></TEST>

...becomes...

xml = {
   tag = "TEST",
   att = {
      foo="Hello",
      bar="World"
   }
   [1] = "Some",
   [2] = {
      tag = "B",
      att = {
         color = "Blue"
      }
      [1] = "Text"
   }
}

It's then a pretty simple case of parsing the ipairs of the table to get the sub-nodes/text whilst having a fixed place for the node names and attributes.

So far I haven't had any problems with this arrangment and have some basic lua functions to work with the structures, which I want to post up on the wiki, once I've given the boss a going over with the open source clue hammer :)

Scott