您好我有以下flex代码,但我不知道如何显示xml的结果。目前textbox的结果是String []但是我需要它来显示xml的结果为100,200,300,400,500谢谢
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:hellos="services.hellos.*"
minWidth="955" minHeight="600">
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
protected function
form_creationCompleteHandler(event:FlexEvent):void
{
sayHelloResult.token = hellos.sayHello();
}
]]>
</fx:Script>
<fx:Declarations>
<hellos:Hellos id="hellos"/>
<s:CallResponder id="sayHelloResult"/>
</fx:Declarations>
<s:Form id="form" creationComplete="form_creationCompleteHandler(event)">
<s:FormItem label="SayHello">
<s:TextInput text="String[]"/>
</s:FormItem>
</s:Form>
</s:Application>
xml如下:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance">
<soapenv:Body>
<sayHelloResponse xmlns="http://services">
<sayHelloReturn>100</sayHelloReturn>
<sayHelloReturn>200</sayHelloReturn>
<sayHelloReturn>300</sayHelloReturn>
<sayHelloReturn>400</sayHelloReturn>
<sayHelloReturn>500</sayHelloReturn>
</sayHelloResponse>
</soapenv:Body>
</soapenv:Envelope>
答案 0 :(得分:1)
在您的标签上添加ID:
<s:TextInput id="resultText" text=""/>
为呼叫响应者的结果事件添加处理程序:
<s:CallResponder id="sayHelloResult" result="processResult()" />
像那样应用响应者:
protected function processResult():void{
var r:Array = [];
for each(var xml:XML in sayHelloResult.lastResult..*::sayHelloReturn){
r.push(xml.toString());
}
resultText.text = r.join(',');
}
在处理xml时,不要忘记命名空间: http://jodieorourke.com/view.php?id=76&blog=news