if your xml is heading towards -
you will need to loop thro' each <main></main> node counting the number of <new > nodes within each.PHP Code:<?xml version="1.0" encoding="UTF-8"?>
<main>
<news>
<new links="link1" mytext="Welcome to 7 Clans Casino | Thief River Falls" />
<new links="link2" mytext="Lunch and Dinner Buffets starting at $11.95" />
</news>
</main>
<main>
<news>
<new links="link3" mytext="Thief River Falls" />
<new links="link4" mytext="Lunch $110.95" />
<new links="link5" mytext="Starting at 4:00pm" />
</news>
</main>
you will need a nested loop to do this -
hthPHP Code:// xml parsing.
xmlParse = function (xmlObj) {
aNode = xmlObj.childNodes;
len1 = aNode.length; trace(len1+" nodes - <main></main>");
for (var i = 0; i<len1; i++) {
len2 = aNode[i].firstChild.childNodes.length; ;
for (var j = 0; j<len2; j++) { trace("<main>"+i+" <new>"+j);
trace(aNode[i].firstChild.childNodes[j].attributes.mytext);
trace(aNode[i].firstChild.childNodes[j].attributes.links)
}
}
};
// --load xml
myXML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = function(){
xmlParse(this);
}
myXML.load("test.xml");
![]()




Reply With Quote