local xmlPath = "myXMLfile.xml"
function getVehiclesInXMLByOwner ( owner )
local vehicles = { } -- Define a Lua table
if ( owner ) then -- If the argument was passed to the function...
local xmlFile = xmlLoadFile ( xmlPath ) -- Load the XML file
if ( xmlFile ) then -- If the XML file is loaded
for _, child in ipairs ( xmlNodeGetChildren ( xmlFile ) ) do -- Loop all it's children
local attrs = xmlNodeGetAttributes ( child ) -- Get the children attributes
if ( attrs.owner == owner ) then -- If the owner matches the passed argument
table.insert ( -- Insert it into our 'vehicles' table
vehicles,
{
id = attrs.vehicleid,
r = attrs.r,
g = attrs.g,
b = attrs.b
}
)
end
end
xmlUnloadFile ( xmlFile ) -- Unload the XML file
end
end
return vehicles -- Return the vehicles table
end
Try it.