Flex获取XML数据
<?xmlversion="1.0"encoding="utf-8"?><mx:Applicationxmlns:mx="http://www.adobe.com/200...
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" horizontalAlign="center" verticalAlign="middle" width="100%" height="100%" fontSize="20"
creationComplete="xmlData.send()">
<mx:HTTPService id="xmlData" url="http://www.flexgrocer.com/units.xml" result="resultHand(event)">
</mx:HTTPService>
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
[Bindable]
private var xmls:ArrayCollection = new ArrayCollection();
[Bindable]
public var i:int = 0;
private function resultHand(event:ResultEvent):void{
// Alert.show("begin.........");
xmls = event.result.allunits.unit; //这一行event.result后面怎么才能访问到XML里面的allunits节点呢?现在访问不到
}
]]>
</mx:Script>
</mx:Application> 展开
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" horizontalAlign="center" verticalAlign="middle" width="100%" height="100%" fontSize="20"
creationComplete="xmlData.send()">
<mx:HTTPService id="xmlData" url="http://www.flexgrocer.com/units.xml" result="resultHand(event)">
</mx:HTTPService>
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
[Bindable]
private var xmls:ArrayCollection = new ArrayCollection();
[Bindable]
public var i:int = 0;
private function resultHand(event:ResultEvent):void{
// Alert.show("begin.........");
xmls = event.result.allunits.unit; //这一行event.result后面怎么才能访问到XML里面的allunits节点呢?现在访问不到
}
]]>
</mx:Script>
</mx:Application> 展开
展开全部
<mx:HTTPService id="xmlData" url="http://www.flexgrocer.com/units.xml" result="resultHand(event)">
</mx:HTTPService>
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
[Bindable]
private var xmls:ArrayCollection = new ArrayCollection();
[Bindable]
public var i:int = 0;
private function resultHand(event:ResultEvent):void{
//xmls = event.result.allunits.unit; //这一行event.result后面怎么才能访问到XML里面的allunits节点呢?现在访问不到
xmls = event.result.allUnits.unit; //比较一下我们的代码差别就在于allunits写错了应该是allUnits
xmls[0].unitName
Alert.show(xmls[0].unitName);
}
]]>
</mx:Script>
</mx:Application>
关键就在与你的allunits写错了,应该是allUnits.
</mx:HTTPService>
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
[Bindable]
private var xmls:ArrayCollection = new ArrayCollection();
[Bindable]
public var i:int = 0;
private function resultHand(event:ResultEvent):void{
//xmls = event.result.allunits.unit; //这一行event.result后面怎么才能访问到XML里面的allunits节点呢?现在访问不到
xmls = event.result.allUnits.unit; //比较一下我们的代码差别就在于allunits写错了应该是allUnits
xmls[0].unitName
Alert.show(xmls[0].unitName);
}
]]>
</mx:Script>
</mx:Application>
关键就在与你的allunits写错了,应该是allUnits.
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询