Mega Code Archive

 
Categories / Flex / Data Model
 

Use XPath to get data

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">     <mx:Script>                  private var xmlItems:XML = <order>                             <item id="1">                                 <menuName>A</menuName>                                 <price>3.9</price>                             </item>                             <item id="2">                                 <menuName>B</menuName>                                 <price>1.5</price>                             </item>                         </order>              private function init():void {               xmlLabel.text = xmlItems.item.(@id == "2").menuName;         }        </mx:Script> <mx:Label id="xmlLabel"/> </mx:Application>