반응형
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Panel width="350" height="220" layout="absolute" horizontalCenter="0" verticalCenter="0">
<mx:DataGrid horizontalCenter="0" verticalCenter="0" dataProvider="{ac}">
<mx:columns>
<mx:DataGridColumn headerText="Name" dataField="ename"/>
<mx:DataGridColumn headerText="Phone" dataField="phone"/>
<mx:DataGridColumn headerText="Email" dataField="email"/>
</mx:columns>
</mx:DataGrid>
</mx:Panel>
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.collections.XMLListCollection;
public var info:XML =
<employees>
<emp>
<ename>scott</ename>
<phone>22-333-3453</phone>
<email>scott@flex.com</email>
</emp>
<emp>
<ename>allen</ename>
<phone>24-233-3456</phone>
<email>allen@flex.com</email>
</emp>
<emp>
<ename>smith</ename>
<phone>23-323-5675</phone>
<email>smith@flex.com</email>
</emp>
<emp>
<ename>ford</ename>
<phone>25-323-3366</phone>
<email>ford@flex.com</email>
</emp>
<emp>
<ename>john</ename>
<phone>27-333-5686</phone>
<email>john@flex.com</email>
</emp>
<emp>
<ename>ward</ename>
<phone>27-243-2356</phone>
<email>ward@flex.com</email>
</emp>
</employees>
public var list:XMLList = info.emp;
public var xc:XMLListCollection = new XMLListCollection(list);
public var ac:ArrayCollection = new ArrayCollection(xc.toArray());
]]>
</mx:Script>
</mx:Application>
반응형