Jump to content

Attribute values.


Guest Guest26901

Recommended Posts

Hi everyone !

How do I get all the attribute values​​? By the following example retrieves only the first attribute values:

  
local meta = xmlLoadFile ( "vehicles.map" ) 
local info = xmlFindChild ( meta, "veh", 0 ) 
local attrs = xmlNodeGetAttributes ( info ) 
for name, value in pairs ( attrs ) do 
     if name == "R" then outputChatBox(value) end 
end 
  

Link to comment

Perhaps this is what you want.

Server-side

local xml = xmlLoadFile("vehicles.map") 
for index,vehicle in ipairs(xmlNodeGetChildren(xml, "veh")) do 
    if xmlNodeGetAttribute(vehicle, "name") == "R" then 
        outputChatBox("ID: " .. index .. ".", root, 255, 255, 255, false) 
        xmlUnloadFile(xml) 
        break 
    end 
end 

Please note that this is server-side. The reason is, because otherwise it would receive information from the client instead of the server.

Link to comment

I did so:

  
    local xml = xmlLoadFile("vehicles.map") 
    local child = xmlNodeGetChildren(xml) 
    for index, vehicle in ipairs ( child ) do 
        outputChatBox("ID: " .. xmlNodeGetAttribute(vehicle, "R") .. ".", root, 255, 255, 255, false) 
    end 
    xmlUnloadFile(xml) 
  

It worked ! Thank you ;)

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