flex中使用DataGrid显示xml

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal" creationComplete="bookDate.send()">
<mx:HTTPService id="bookDate" url="huiyuan.xml" />
 


<mx:DataGrid width="825.5" height="377" dataProvider="{bookDate.lastResult.NewDataSet.NewView}"  enabled="true">
<mx:columns>
<mx:DataGridColumn headerText="序列号" dataField="id"  width="100"/>
<mx:DataGridColumn headerText="姓名" dataField="name"/>
<mx:DataGridColumn headerText="电话" dataField="phone"/>
<mx:DataGridColumn headerText="邮件" dataField="mail"/>
</mx:columns>
</mx:DataGrid>
<mx:Style source="fcss.css"/>
     
</mx:Application>

xml数据文件格式 

 <?xml version="1.0" standalone="yes"?>

<NewDataSet>

  <NewView>

    <id>4804</id>

    <name>韩xx</name>

    <mail>zzz@163.com</mail>

    <phone>zz226280</phone>    

  </NewView>

  <NewView>

    <id>4802</id>

    <name>吴ss</name>

    <mail>ddmm@gmail.com</mail>

    <phone>13062121dfd8</phone>   

  </NewView>

 </NewDataSet>

原文地址:https://www.cnblogs.com/fslnet/p/1846671.html