PHP Code:
names = [];
images = [];
_xml = new XML();
_xml.ignoreWhite = true;
_xml.load("people.xml");
_xml.onLoad = function(){
nodes = this.firstChild.childNodes;
len = nodes.length;
for(var n=0;n!=len;n++){
names[n] = nodes[n].firstChild.childNodes.toString();
images[n] = nodes[n].firstChild.nextSibling.childNodes.toString();
}
};
/* this produces two arrays -
Variable _level0.names = [object #1, class 'Array'] [
0:"sara",
1:"manju",
2:"sind"
]
Variable _level0.images = [object #2, class 'Array'] [
0:"image1.jpg",
1:"image2.jpg",
2:"image3.jpg"
]
*/
PHP Code:
<people>
<student>
<name>sara</name>
<image>image1.jpg</image>
</student>
<student>
<name>manju</name>
<image>image2.jpg</image>
</student>
<student>
<name>sind</name>
<image>image3.jpg</image>
</student>
</people>