This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
timia2109's profile picture

Parse XML

Started by timia2109, 04 November 2014 - 04:44 PM
timia2109 #1
Posted 04 November 2014 - 05:44 PM
Hey everyone,
I want to ask, if anyone can show me how I can parse XML Values.
I want something like this (basic XML)

<key attribute=value>value</key>
I want the following things:
the Key, the attributes (as one String is ok), and the value.
But it should also support things like that (Tag in Tag) (I havn't a better example :/):

<cars>
   <Audi>
	  A8
   </Audi>
</cars>

I want also use that for other parsers, so it would be cool if you can make it so, that I can change that and use that for other things.

I hope anyone can help me.
Thanks a lot!
Timia2109

(Sorry for my bad english)
MKlegoman357 #2
Posted 04 November 2014 - 08:02 PM
Well, this isn't a place to ask for code. But you should try to google a simple XML parser for Lua, I'm sure there are more than enough for you.
willwac #3
Posted 14 December 2014 - 12:50 AM
I have not tried this out, but I found this: http://www.computercraft.info/forums2/index.php?/topic/11606-html-and-xml-parser/
theoriginalbit #4
Posted 14 December 2014 - 02:33 AM
As MKlegoman357 stated, Ask a Pro isn't here to request code be made for you, instead it is for help with code you're creating when you get stuck on a problem. If you want someone to make something for you there is a thread for that over in General.

However since this is a simple problem, I'll answer it by saying I've personally found the solution at the very bottom of this page to work fantastically to parse XML.

I want also use that for other parsers, so it would be cool if you can make it so, that I can change that and use that for other things.
it is very hard to accomplish, languages and standards are too diverse to be able to make something so generic in order to parse them