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( ) ) { trace( element.@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>;
walk( menu );
function walk( node:XML ):void { for each ( var element:XML in node.elements( ) ) { trace( element.@label ); walk( element ); } } } } }
Related Scripts with Example Source Code in same category :