Hi Folks,
I am finally reading the Lua tutorials and noticed something. The Lua tables, how they can be nested, lend themselves perfectly to saving them as an xml file. When I imagine that I could save a lua table to xml, or read an xml file from the internet and access it as a nested lua table, I get all warm inside.
I'm not talking about the whole namespace, document template and so on, that would be more suitable for a full-fledged xml module. I would even ignore attributes. Perhaps only support CDATA sections (the <![CDATA[some text with annoying characters reserved for xml formatting]]> bit).
But the table structure and flexibility just really lends itself so well for it! It could be linked to database access and what not - I could just write an http request to an asp or php page, and get an xml string back that reads into a (nested) Lua table. I could save my tables holding my configuration and settings with one command to xml files on the memory stick.
All it would need is a save lua table command. Of course I could just write one in Lua, but this would serve such basic needs, I think nearly every single program could (and would) use it. Even those who don't care about xml will appreciate being able to save and load a(n optionally nested) table like that.
Or am I wrong?
(goes back to reading)
Lua Table to XML (and Back)
Moderators: Shine, Insert_witty_name
I am using tables write now to download ini-style files and read them right into a lua table... it works extremely well :) Its nice to just read in the key/value items for things, and they can be easily accessed.
[Name]
Desc=nifty stuff
Whatever=275
item[x].Name
item[x].Desc
item[x].Whatever
Certainly a nested table would be useful for xml. It's why I am suprised that we haven't had a working rss reader in lua yet... still waiting :P
liquid8d
[Name]
Desc=nifty stuff
Whatever=275
item[x].Name
item[x].Desc
item[x].Whatever
Certainly a nested table would be useful for xml. It's why I am suprised that we haven't had a working rss reader in lua yet... still waiting :P
liquid8d
Re: Lua Table to XML (and Back)
Why everyone wants XML? For Lua in my opinon it is much easier to save nested tables in Lua source format and just execute the file when loading it :-)Arwin wrote:All it would need is a save lua table command. Of course I could just write one in Lua, but this would serve such basic needs, I think nearly every single program could (and would) use it. Even those who don't care about xml will appreciate being able to save and load a(n optionally nested) table like that.
Or am I wrong?
Re: Lua Table to XML (and Back)
Because XML is a widely used standard. Sure, using Lua source format works, but I have been using XML for this kind of thing in several languages for five years now, and others are picking it up also. I could just save some data from a database, and Lua could pick it up as a table and use it. Simple as that. And the other way around. Just one of many examples.Shine wrote:Why everyone wants XML? For Lua in my opinon it is much easier to save nested tables in Lua source format and just execute the file when loading it :-)Arwin wrote:All it would need is a save lua table command. Of course I could just write one in Lua, but this would serve such basic needs, I think nearly every single program could (and would) use it. Even those who don't care about xml will appreciate being able to save and load a(n optionally nested) table like that.
Or am I wrong?
You may find it trivial, probably from not using XML for anything at the moment. But supporting XML like that would not be less trivial than supporting PNG files. They are both widely accepted standards, one for graphics, the other for data.
possibly this might help:
LUA to XML parser
greets
lumo
PS: might be another nice 'plugin' for luaplayer
LUA to XML parser
greets
lumo
PS: might be another nice 'plugin' for luaplayer