Generating xml:
PHP Code:
temp.xml = "";
with (temp.xml.addArrayMember("friends")) {
for (temp.pl: allplayers) {
with (addArrayMember("friend")) {
addArrayMember("account").addArrayMember("text") = temp.pl.account;
addArrayMember("nick").addArrayMember("text") = temp.pl.nick;
}
}
}
player.sendToClient("friends", temp.xml.savexmltostring());
Reading XML:
PHP Code:
temp.xml.loadxmlfromstring(data);
if (temp.xml.size() >= 1 && temp.xml[0].name=="friends") {
for (temp.i=0; temp.i<temp.xml[0].size(); temp.i++) {
if (temp.xml[0][temp.i].name=="friend") {
echo("account: " @ temp.xml[0][temp.i].getArrayMember("account").text);
echo("nick: " @ temp.xml[0][temp.i].getArrayMember("nick").text);
}
}
}
You can also use node attributes, there are some small things to keep care of though, "name" will be renamed to "xmlname", and "text" will automatically hold the first "text" attribute.