Jump to content

XML opening issues (?)


Recommended Posts

Hi all. I have this script that loads locations from an XML file. Apparently, there is a bad argument at line 3 (xmlRootGetChildren) so it wont return a table, triggering another error (expected tables, got nil).

server.lua

  
function getTaxiLocations() 
    local root = getResourceConfig("locations.xml") 
    local taxiNodes = xmlNodeGetChildren(root) 
    for _,node in pairs(taxiNodes) do 
    local atributes = xmlNodeGetAttributes(node) 
    local id = atributes.id 
    local name = atributes.name 
    local price = atributes.price 
    triggerClientEvent ( source, "sendTaxiLocations", source, id, name, price) 
    end 
    xmlUnloadFile(root)  
end 
addEvent( "getTaxiLocations", true ) 
addEventHandler( "getTaxiLocations", getRootElement(), getTaxiLocations) 
  

locations.xml

  
<root> 
    <location id="1" name="Some random street" price="10000" posX="2049.38671875" posY="1535.5419921875" posZ="10.671875" /> 
</root> 
  

Any advice would be appreciated. tysm

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...