'LinKin Posted July 10, 2014 Posted July 10, 2014 Hello, I'm trying to modify a child into a xml file that stores some teams. How could I for example; find and change an attribute? I got this: <team name="Street Warriors" tag="|SW|" color="#00FFFF" aclGroup="GMC" required="both"></team> <team name="Team 1" tag="|T1|" color="#990000" aclGroup="-" required="tag"></team> <team name="Team 2" tag="|T2|" color="#009900" aclGroup="-" required="tag"></team> <team name="Team 3" tag="|T3|" color="#000099" aclGroup="-" required="tag"></team> So if I wanted to change 'Team 2' color to #FF00FF so that it becomes like this: <team name="Street Warriors" tag="|SW|" color="#00FFFF" aclGroup="GMC" required="both"></team> <team name="Team 1" tag="|T1|" color="#990000" aclGroup="-" required="tag"></team> <team name="Team 2" tag="|T2|" color="#FF00FF" aclGroup="-" required="tag"></team> <team name="Team 3" tag="|T3|" color="#000099" aclGroup="-" required="tag"></team> how could I do it? I want to make the search based on the 'name' attribute.
MTA Team botder Posted July 10, 2014 MTA Team Posted July 10, 2014 function saveTeamColor(file, team, color) local rootnode = xmlLoadFile(file) if (not rootnode) then return end local index, node = 0, false repeat node = xmlFindChild(rootnode, "team", index) if (node) then local name = xmlNodeGetAttribute(node, "name") if (name and name == team) then xmlNodeSetAttribute(node, "name", tostring(color)) xmlUnloadFile(rootnode) break end index = index + 1 end until (node) xmlUnloadFile(rootnode) end
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now