0
如何知道何時遇到具有名稱空間的節點,以及何時可以提取該名稱空間的名稱和URL?如何知道屬性或節點是否有不同的名稱空間?
XML:
<s:Image xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:test="library://ns.test.com/flex/"
visible="false"
test:locked="true" />
XML解析代碼:
public static function getAttributeNames(node:XML):Array {
var result:Array = [];
var attributeName:String;
for each (var attribute:XML in node.attributes()) {
attributeName = attribute.name().toString();
result.push(attributeName);
}
return result;
}
trace (result);
[0] visible
[1] library://ns.test.com/flex/::locked
我能爲做一次檢查。 「::」 的字符串,但似乎累贅。一定會有更好的辦法。