Flex读取XML文件中的数据

2019-04-15 13:22发布

[img]http://dl.iteye.com/upload/picture/pic/116117/d9a58f3a-214a-3ae0-8ac1-018ea1002132.png[/img]

[img]http://dl.iteye.com/upload/picture/pic/116119/e8431fe3-792a-35f3-ba3e-3f34b51bc4b7.png[/img]



395


196


177


167


150


125


102


100


100


100



backgroundColor="#FFFFFF" creationComplete="init()" layout="absolute">

import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
import mx.rpc.http.HTTPService;

public const xmlUrl:String = "RankingSystem_201207_4.xml";
[Bindable] private var rankingListXml1:ArrayCollection;
[Bindable] private var rankingListXml2:XML;

private function init():void{
//方法一:通过HTTPService
var service:HTTPService = new HTTPService();
service.url = xmlUrl;
service.addEventListener(ResultEvent.RESULT, resultHandler);
service.send();

//方法二:通过URLLoader
var request:URLRequest = new URLRequest(xmlUrl);
var loader:URLLoader = new URLLoader(request);
loader.addEventListener(Event.COMPLETE, loaderCompleteHandler);
}

private function resultHandler(event:ResultEvent):void{
rankingListXml1 = event.result.rankingListXml.list;
}

private function loaderCompleteHandler(event:Event):void{
rankingListXml2 = new XML(event.target.data);
}
]]>

labelField="cardNum"/>
labelField="sumMoney"/>
labelField="@cardNum"/>