The XMLListCollection class provides collection functionality to an XMLList object and makes available some of the methods of the native XMLList class.
CompanyDetails.xml
<?xml version=”1.0″ ?> <content> <item> <Company>Google</Company> <Feature>Search Engine / Mail / Social Media</Feature> <url>www.google.com</url> </item> <item> <Company>Yahoo</Company> <Feature>Search Engine / Mail</Feature> <url>www.yahoo.com</url> </item> </content> |
MXML
<?xml version=”1.0″ encoding=”utf-8″?> <mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”absolute” creationComplete=”onCreate(event)”> <mx:Script> <![CDATA[ import mx.collections.XMLListCollection; import mx.controls.Alert; import mx.collections.ArrayCollection; private function openXMLValues(e:Event):void { var XMLConv:XMLList=new XMLList(e.target.data) var XMLL:XMLListCollection=new XMLListCollection(XMLConv.item) // now it points to the “item” node. XMLListCollection can hold only the XMLList DG.dataProvider=XMLL; } private function onCreate(e:Event):void { var XMLLoader:URLLoader=new URLLoader(new URLRequest(“c:\\CompanyDetails.xml”)) XMLLoader.addEventListener(Event.COMPLETE,openXMLValues) } ]]> </mx:Script> <mx:DataGrid x=”21″ y=”25″ width=”388″ height=”220″ id=”DG”> <mx:columns> <mx:DataGridColumn dataField=”Company” /> <mx:DataGridColumn dataField=”Feature” /> </mx:columns> </mx:DataGrid> </mx:Application> |