Dimitree
Dimitree

Reputation: 211

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

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>?

Upvotes: 1

Views: 2265

Answers (2)

gregtzar
gregtzar

Reputation: 2508

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
}

Upvotes: 3

Dimitree
Dimitree

Reputation: 211

used this simple code which worked:

if ("pp" in XMLlist) {

trace("exist");

}

Upvotes: 1

Related Questions