How to parse XML to flex Data Grid contents.

Posted by Jeeva on Stack Overflow See other posts from Stack Overflow or by Jeeva
Published on 2010-03-12T04:19:20Z Indexed on 2010/03/12 4:27 UTC
Read the original article Hit count: 265

Filed under:
|

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.

© Stack Overflow or respective owner

Related posts about flex

Related posts about Xml