Jump to content

Load Remote XML File


Recommended Posts

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 by Guest
Link to comment

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) 

  • Like 1
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...