datagrid.mxml-----------------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
creationComplete="srv.send()"><!-- 发送HTTPService请求-->
<mx:Script >
<![CDATA[
import mx.collections.XMLListCollection;
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
[Bindable]
private var users:XML;
private function resultUsers(event:ResultEvent):void{//处理结果
users = XML(event.result);
datagrid.dataProvider=users.children();//XMLList
}
]]>
</mx:Script>
<mx:HTTPService url="user.xml" useProxy="false" id="srv" resultFormat="xml" result="resultUsers(event)"><!--处理结果函数-->
</mx:HTTPService>
<mx:Panel x="416" y="75" width="458" height="269" layout="absolute" id="panel" title="用户信息" fontSize="14" fontWeight="bold" fontFamily="Verdana" color="#BB8BDD" borderStyle="solid" borderThickness="3" borderColor="#0E0505" cornerRadius="20" themeColor="#A3C2D8" alpha="0.85" backgroundColor="#FFFFFF" backgroundAlpha="0.84">
<mx:DataGrid x="32" y="10" width="374" height="193" id="datagrid" enabled="true" fontSize="13" fontWeight="bold" textAlign="center" color="#526BBE" borderColor="#C0C8CC" themeColor="#A9B1B3" alpha="0.86" alternatingItemColors="[#E9E9E9, #EFF8F9]" borderStyle="inset">
<mx:columns>
<mx:DataGridColumn headerText="ID" dataField="ID"/>
<mx:DataGridColumn headerText="姓名" dataField="name"/>
<mx:DataGridColumn headerText="年龄" dataField="age"/>
</mx:columns>
</mx:DataGrid>
</mx:Panel>
</mx:Application>
--------------------user.xml--------------------------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<users>
<user>
<ID>213001</ID>
<name>飞机</name>
<age>22</age>
</user>
<user>
<ID>213003</ID>
<name>痞子</name>
<age>23</age>
</user>
<user>
<ID>213006</ID>
<name>嗨嗨</name>
<age>22</age>
</user>
<user>
<ID>213013</ID>
<name>小强</name>
<age>21</age>
</user>
<user>
<ID>213015</ID>
<name>萧萧</name>
<age>22</age>
</user>
<user>
<ID>213016</ID>
<name>小敏</name>
<age>22</age>
</user>
</users>
文章出处:http://www.diybl.com/course/4_webprogram/xml/xml_js/200855/113849.html