使用AS3的SOAP XML
问题描述:
在过去的几个小时里,我一直在撞墙,并且需要一些关于如何解决(我认为很奇怪)问题的建议。使用AS3的SOAP XML
我连接到一个.NET web服务,并传递给它几个参数并找回一些XML包装在SOAP中。
我发现通过所有的SOAP头来获得我想要交互的数据非常繁琐。看起来你不能像普通的XML那样迭代它。 (0)[0] [0] .toXMLString());返回页首返回页首返回页首返回页首返回页首返回页首返回页首返回页首
所以无论如何,当我从WebService描绘出我的XML我得到这个:
<data xmlns="http://services.xxx.com" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<CurrencyPrice>
<CurrencyID>8</CurrencyID>
<CurrencyFlagImagePath/>
<MidRate>x.xxxx</MidRate>
<CurrencyCode>AUD</CurrencyCode>
<CurrencyName>Australian Dollar (AUD)</CurrencyName>
<BaseCurrency>GBP</BaseCurrency>
<CurrencyChartURL/>
</CurrencyPrice>
</data>
现在如果我通常会使用跟踪(xml.CurrencyPrice [0]);查看第一个CurrencyPrice节点。但我得到一个不确定的。如果我复制出来的原始跟踪和手动创建XML,并删除所有xlmns属性
var xml:XML = <data>
<CurrencyPrice>
<CurrencyID>8</CurrencyID>
<CurrencyFlagImagePath/>
<MidRate>x.xxxx</MidRate>
<CurrencyCode>AUD</CurrencyCode>
<CurrencyName>Australian Dollar (AUD)</CurrencyName>
<BaseCurrency>GBP</BaseCurrency>
<CurrencyChartURL/>
</CurrencyPrice>
</data> ;
然后跟踪(xml.CurrencyPrice [0])中的数据;
Boom得到一些我可以使用的XML。
所以我的问题是如何删除标题中的属性我尝试使用删除方法定位。@ xlmns。不做任何事情,或以任何其他方式绕过它。
我将不胜感激任何意见,因为它使用了我的垃圾我没有得到任何地方。
干杯
城野
答
使用的命名空间,您需要使用AS3中的命名空间声明。
public namespace soap = "http://schemas.xmlsoap.org/soap/envelope/";
然后,你将能够与访问子属性:
trace(xml.soap::CurrencyPrice.soap::CurrencyID);
然而,当你使用多个名称空间它会看起来更凌乱。我从其他似乎有同样问题的人那里找到了这个参考,但只有两个命名空间。我不知道如何用四个看!
http://headwindslab.net/2009/01/29/parsing-multiple-namespaces-in-as3/
祝你好运! :)
答
难道你不能这样说吗?
var raw:String = xml.toXMLString();
//filter the String of namespaces
//and then recreate the xml
var clean:XML = new XML(raw);
然后明明做你的正常的XML的做法....
trace(clean.CurrencyPrice[0]);