Reading Elements in an XML Tree : XML Object : XML Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » XML » XML Object »

 

Reading Elements in an XML Tree


 

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


        var menu:XML = <menu>
                         <menuitem label="File">
                           <menuitem label="New"/>
                         </menuitem>
                         <menuitem label="Help">
                           <menuitem label="About"/>
                         </menuitem>
                         This is a text node
                       </menu>;
        
        for each var element:XML in menu.elements(  ) ) {
          traceelement.@label );
        }
        var menu:XML = <menu>
                         <menuitem label="File">
                           <menuitem label="New"/>
                         </menuitem>
                         <menuitem label="Help">
                           <menuitem label="About"/>
                         </menuitem>
                         This is a text node
                       </menu>;
        
        walkmenu );
        
        function walknode:XML ):void {
          for each var element:XML in node.elements(  ) ) {
            traceelement.@label );
            walkelement );
          }
        }
    }
  }
}

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo XML
» XML Object