PDA

View Full Version : using Xml hasChildNodes() in AS3


Axon Terminal
10-16-2008, 06:51 AM
Right, my first post after years of finding answers on this site.

I'm trying to parse xml like so:
var myXML:XML = <body>
<channel>
<item title="num1"/>
<item title="num2">
<item title="sub1"/>
</item>
<item title="num3"/>
<item title="num4"/>
</channel>
</body>;
var myXMLList = myXML;
trace (myXMLList);
for (var item:String in myXMLList.channel.item){
if (myXMLList.channel.item[item].hasChildNodes()){
trace ("item # " + myXMLList.channel.item[item].@title);
}
};

now the problem is the "hasChildNodes" in the if statement, I get an error when I type it with the brackets, but it doesn't catch anything if I don't...am I addressing wrong? what's the deal?