laserlaser Posted November 18, 2010 Posted November 18, 2010 Hello,i write a new useful function.This name is getXMLNodes,good! My name is |OS|Bikers! in MTA! The Codes: function getXMLNodes(xmlfile,nodename) local xml = xmlLoadFile(xmlfile) if xml then local ntable={} local a = 0 while xmlFindChild(xml,nodename,a) do table.insert(ntable,a+1) ntable[a+1]={} local attrs = xmlNodeGetAttributes ( xmlFindChild(xml,nodename,a) ) for name,value in pairs ( attrs ) do table.insert(ntable[a+1],name) ntable[a+1][name]=value end ntable[a+1]["nodevalue"]=xmlNodeGetValue(xmlFindChild(xml,nodename,a)) a=a+1 end return ntable else return {} end end Example USE: local aTeam = getXMLNodes("teams.xml","team") for ka,vc in ipairs(aTeam) do outputDebugString(vc.tag) end Made in Turkey! War of Empire LUA TEAM!
greacius Posted November 18, 2010 Posted November 18, 2010 Oke... what's so usefull about this...? http://AllesOverServers.nl http://www.zakelijkthuis.nl/promoot.php?x=4179
laserlaser Posted November 18, 2010 Author Posted November 18, 2010 Oke... what's so usefull about this...? Time to good use,More quickly...There is no unnecessary code Ty for reply my topic
dzek (varez) Posted November 18, 2010 Posted November 18, 2010 You can put this on MTA wiki if you want. https://wiki.multitheftauto.com/wiki/Useful_Functions Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online! programista php rzeszów Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting. Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!
laserlaser Posted November 18, 2010 Author Posted November 18, 2010 You can put this on MTA wiki if you want.https://wiki.multitheftauto.com/wiki/Useful_Functions yes i want but how to ?
dzek (varez) Posted November 18, 2010 Posted November 18, 2010 You need to login with Open ID to wiki (click "Log in with OpenID" on the top-right). Before you need to have Open ID account. if you dont have it - register it for example: here (btw: according to existing xml functions it will be better to name your function xmlGetNodes) after login go to: https://wiki.multitheftauto.com/wiki/XmlGetNodes and press "edit" link. if you dont know anything about wiki syntax, you can check another function wiki source (like this one - result) fill your function page, and save it. you are done. Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online! programista php rzeszów Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting. Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!
greacius Posted November 18, 2010 Posted November 18, 2010 Oke... but it only gets the value, not the attributes, and what if there isnt any value? http://AllesOverServers.nl http://www.zakelijkthuis.nl/promoot.php?x=4179
laserlaser Posted November 18, 2010 Author Posted November 18, 2010 Oke... but it only gets the value, not the attributes, and what if there isnt any value? if there isn't any value return "" else return node value if there isn't any attr then return table hasn't attr
Callum Posted November 18, 2010 Posted November 18, 2010 It's more efficient to do a loop for the XML children, instead of looping a table, which used another loop to be generated. Retired
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