Processing XML with for-each-in and for-in : loop through « XML « Flash / Flex / ActionScript






Processing XML with for-each-in and for-in

 

package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){
        var novel:XML = <BOOK ISBN="0000000000">
            <TITLE>ActionScript</TITLE>
            <AUTHOR>J, J</AUTHOR>
            <PUBLISHER>Books Ltd</PUBLISHER>
          </BOOK>;
        
        for each (var child:XML in novel.*) {
          trace(child);
        }
    }
  }
}

        








Related examples in the same category

1.Use for loop to go through the xml data
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: