victormgons Posted August 7, 2016 Posted August 7, 2016 (edited) Hello everyone, I'm trying do download a XML file from a server-side script and load it to get informations, I made this script but isn't working... Can anyone help me? function returnFunction(responseData,errno) file = xmlLoadFile(responseData) for i,node in pairs(xmlNodeGetChildren(file))do outputChatBox(xmlNodeGetName(node)) end end fetchRemote("http://www.w3schools.com/xml/note.xml",returnFunction) Edited August 7, 2016 by Guest
Musamba Posted August 7, 2016 Posted August 7, 2016 Is the variable "sla" in "outputChatBox(xmlNodeGetName(sla))" defined?
victormgons Posted August 7, 2016 Author Posted August 7, 2016 I forgot to change before post here... But it gives this error: Server.lua:3: bad argument #1 to 'pairs' (table expected, got boolean)
ozulus Posted August 7, 2016 Posted August 7, 2016 Here you go, not tested hope it works. You must write response data that you got it from link or somewhere else.. function returnFunction(responseData, errno) if (errno == 0) then local file = fileExists("test.xml") and fileOpen("test.xml") or fileCreate("test.xml") fileWrite(file, responseData) fileClose(file) local file = xmlLoadFile("test.xml") for i, node in pairs(xmlNodeGetChildren(file))do outputChatBox(xmlNodeGetName(node), root) end xmlUnloadFile(file) --added end end fetchRemote("http://www.w3schools.com/xml/note.xml", returnFunction) 1
victormgons Posted August 7, 2016 Author Posted August 7, 2016 Thank you so much. It works perfectly! 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now