For that structure you need to slightly modify your table - first, to loop through each group, and secondly, to prevent duplicate entries (I believe the freeroam skins XML can have the same skin under different groups)
local tabla = {}
function XmlToTable()
local added = {} -- table to keep track of which skins were added to prevent duplicates
local xml = xmlLoadFile("skins.xml") -- load the xml
local groups = xmlNodeGetChildren(xml) -- the the xml root's children nodes
if groups then
for i, group in ipairs(groups) do -- loop the xml root's children nodes
local skins = xmlNodeGetChildren(group) -- the the group's children nodes
if skins then
for j, skin in ipairs(skins) do -- loop the group's children nodes
local id = tonumber(xmlNodeGetAttribute(skin, "id")) -- ensure you convert the string to a number, if impossible, a nil is returned - this is caught by the next if statement
if id and not added[id] then -- if tonumber didn't fail and the id wasn't yet added
table.insert(tabla, id) -- add it
added[id] = true -- and prevent it from being added again
end
end
end
end
end
xmlUnloadFile(xml) -- unload now that we're done with this
end
addEventHandler("onClientResourceStart", resourceRoot, XmlToTable) -- if this script is clientside
addEventHandler("onResourceStart", resourceRoot, XmlToTable) -- if this script is serverside
function teszt()
for k, v in ipairs(tabla) do
outputChatBox(v)
end
end
addCommandHandler("asd",teszt)
I've also noticed that "expected string at argument 1, got table" error is caused by storing tables within tabla instead of skin IDs - this originates from a typo in your code where you've written xmlNodeGetAttributes instead of xmlNodeGetAttribute.