我想在我的AS3 Flash文件中使用此xml文件进行货币兑换:
http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml
到目前为止,这就是我所拥有的:
var myXML:XML;
var myLoader:URLLoader = new URLLoader();
myLoader.load(new URLRequest("http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml"));
myLoader.addEventListener(Event.COMPLETE, processXML);
function processXML(e:Event):void {
myXML = new XML(e.target.data);
trace(myXML.*);
}
有了这个,我得到整个xml文档作为输出。
如何在as3中添加各种“立方体货币”和“费率”值?
感谢您的帮助!
答案 0 :(得分:2)
function processXML(e:Event):void {
myXML = new XML(e.target.data);
//set default xml to "", this allow to access to he Cube nodes by name
var ns:Namespace = myXML.namespace("");
default xml namespace = ns;
//list of Cube nodes
var list:XMLList = myXML.Cube.Cube.*;
var currency:String;
var rate:Number;
for each(var node:XML in list)
{
currency = String(node.@currency[0]);
rate = node.@rate[0];
trace(currency, rate);
}
}