Use for loop to go through the xml data : loop through « XML « Flash / Flex / ActionScript






Use for loop to go through the xml data

 

package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){

        var order:XML = <ORDER>
          <ITEM SKU="374">
            <NAME>Toy</NAME>
            <PRICE>39.99</PRICE>
            <QUANTITY>2</QUANTITY>
          </ITEM>
        </ORDER>
        
        for (var childName:String in order.*) {
          trace(childName);
        }

    }
  }
}

        








Related examples in the same category

1.Processing XML with for-each-in and for-in
2.Accessing Descendants
3.Create Date object from xml data
4.Use for each loop to access the attributes
5.Iterating through the Children of an Element
6.Use the for..in or for each..in statements to iterate through an XMLList.
7.Tree traversal: converts every element and attribute name to lowercase: