Mega Code Archive

 
Categories / Flex / Data Model
 

Looping over an XML fragment

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"     backgroundColor="white" creationComplete="tryme()">     <mx:XML id="usersXML">         <root>             <users>                 <user id="1">                     <firstname>A</firstname>                     <lastname>A</lastname>                 </user>                 <user id="2">                     <firstname>H</firstname>                     <lastname>H</lastname>                 </user>             </users>         </root>     </mx:XML>     <mx:Script>                  [Bindable]         public var infoString:String = "";         public function tryme():void         {             var xmlFragment:XMLList = usersXML.users.user;             for each(var node:XML in xmlFragment)             {                 infoString = infoString + node.firstname;                 infoString = infoString + node.lastname;             }         }            </mx:Script>     <mx:TextArea text="{infoString}" width="250" height="100" /> </mx:Application>