| View previous topic :: View next topic |
| Author |
Message |
Arwin
Joined: 12 Jul 2005 Posts: 426
|
Posted: Fri Jan 13, 2006 10:12 pm Post subject: Lua Table to XML (and Back) |
|
|
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) |
|
| Back to top |
|
 |
liquid8d
Joined: 30 Jun 2005 Posts: 66
|
Posted: Sat Jan 14, 2006 4:15 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
MikeHaggar
Joined: 18 Jul 2005 Posts: 116
|
Posted: Sun Jan 15, 2006 4:05 am Post subject: |
|
|
| Hmm... What does pspRSS do then? |
|
| Back to top |
|
 |
Shine
Joined: 03 Dec 2004 Posts: 728 Location: Germany
|
Posted: Sun Jan 15, 2006 4:22 am Post subject: Re: Lua Table to XML (and Back) |
|
|
| 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?
|
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 :-) |
|
| Back to top |
|
 |
Arwin
Joined: 12 Jul 2005 Posts: 426
|
Posted: Sun Jan 15, 2006 10:35 am Post subject: Re: Lua Table to XML (and Back) |
|
|
| Shine wrote: | | 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?
|
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 :-) |
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.
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. |
|
| Back to top |
|
 |
LuMo
Joined: 21 Aug 2005 Posts: 410 Location: Austria
|
Posted: Sun Jan 15, 2006 8:41 pm Post subject: |
|
|
possibly this might help:
LUA to XML parser
greets
lumo
PS: might be another nice 'plugin' for luaplayer _________________ "Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com |
|
| Back to top |
|
 |
modsyn
Joined: 27 Sep 2005 Posts: 28
|
Posted: Tue Jan 17, 2006 8:07 am Post subject: |
|
|
i would love an XML/html to table function.
or at least the ability to drop in plugins. :) |
|
| Back to top |
|
 |
|