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

Lua and xml

Started by PrinzJuliano, 05 January 2014 - 09:50 AM
PrinzJuliano #1
Posted 05 January 2014 - 10:50 AM
Hello folks,

I got the following situation: I am creating a rednet protocol. .. long story no sense. I send the data with xml. Is there a way to turn xml to a table?

Thank you. You are the best.
LBPHacker #2
Posted 05 January 2014 - 10:57 AM
Sure there is. Anyway. What about using serialized tables instead of XML?
Edited on 05 January 2014 - 09:58 AM
PrinzJuliano #3
Posted 05 January 2014 - 11:58 AM
The thing is… i want to use it for more than this… Since my tomcat webservice comunicates in xml, i need an api like


var xmlFile = xml.parseFile(file) -- returns table
var docs = xml.getElements(xmlFile, "user") --returns all elements with <user></user> Tag.

--and than i use the docs for like
print(docs[1].name, ", ", docs[1].id)
-> PrinzJuliano, 5

Thanks
LBPHacker #4
Posted 05 January 2014 - 12:14 PM
There are XML parsers out there on the web, but I might end up writing an XML API for CC. If anybody has already written a working one, tell us.
InputUsername #5
Posted 05 January 2014 - 01:41 PM
I found an XML parser. Haven't tested it myself, but I think it looks good: https://github.com/Phrogz/SLAXML