Use the length( ) method to count the number of elements found: trace( items.item.length( ) );
package{
import flash.display.Sprite;
public class Main extends Sprite{
public function Main(){
// To examine every element node with a particular node name, use a for each loop
var items:XML = <items>
<item>
<name>Apple</name>
<color>red</color>
</item>
<item>
<name>Orange</name>
<color>orange</color>
</item>
</items>;
for each ( var name:XML in items..name ) {
trace( name );
}
}
}
}
Related examples in the same category