How can you tell if an XMLlist object in AS3 contains a node?

2.2k Views Asked by At

How can you tell if an XMLlist object in AS3 contains a specific node? For ex: you have this XML file

<items> <item>one</items> </items>

And want to check if in this file exists a child with tag <pp>?

2

There are 2 best solutions below

0
On

used this simple code which worked:

if ("pp" in XMLlist) {

trace("exist");

}

0
On
var xml:XML = <items>  <item>one</items>  </items>;

// my favorite method (works also for testing attributes)

if (xml.pp.length()) {
   // xml contains one or more <pp> child elements
}
else {
   // xml contains no <pp> child elements
}