我有一个结构如下的XML,我想在AS3中获取currency属性,而不管SellTotosystem标记,因为我每次都会有不同的标记。
<GCPRequest version="1" requestId="1234567890">
<SellTotoSystem currency = "EUR">
</SellTotoSystem>
</GCPRequest>
答案 0 :(得分:1)
您可以使用以下示例之一:
var xml:XML = <GCPRequest version="1" requestId="1234567890">
<SellTotoSystem currency = "EUR"></SellTotoSystem>
</GCPRequest>;
var currency:String;
//first child at the first level of tree
currency = xml.*.@currency[0];
trace(currency);
//first encounted child at any level of tree
currency = xml..@currency[0];
trace(currency);
//output:
EUR
EUR