How to parse XML to flex Data Grid contents.
- by Jeeva
My xml file which is in a webserver is show below.
<root>
<userdetails>
<username>raja</username>
<status>offline</status>
</userdetails>
<userdetails>
<username>Test</username>
<status>online</status>
</userdetails>
</root>
How can i parse this to flex data grid contents.
I tried with below coding
< ?xml version="1.0" encoding="utf-8"?
< mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="initApp()"
< mx:HTTPService id="userList" result="handleData(event)"
resultFormat="object" url="http://apps.facebook.com/ajparkin/user_list.xml" /
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
import mx.controls.Alert;
public function initApp():void
{
userList.send();
}
[Bindable]
var userdetailsArray:ArrayCollection;
private function handleData(evt:ResultEvent):void
{
this.userdetailsArray= evt.result.userdetails;
}
]]>
</mx:Script>
<mx:DataGrid dataProvider="{userdetailsArray}">
<mx:columns>
<mx:DataGridColumn dataField="username" headerText="User Name"/>
<mx:DataGridColumn dataField="status" headerText="Status" />
</mx:columns>
</mx:DataGrid>
</mx:Application>
I'm getting only the field names not the data.