我一直在使用这个XML,但我无法获得带元素运算符的节点列表:
<s:LinearGradient rotation="90" xmlns:s="library://ns.adobe.com/flex/spark">
<s:GradientEntry color="0x000000" alpha="0.8"/>
<s:GradientEntry color="0xFFFFFF" alpha="0.8"/>
</s:LinearGradient>
这是我的AS3:
var fillXML:XML = <s:LinearGradient rotation="90" xmlns:s="library://ns.adobe.com/flex/spark">
<s:GradientEntry color="0x000000" alpha="0.8"/>
<s:GradientEntry color="0xFFFFFF" alpha="0.8"/>
</s:LinearGradient>;
var entriesXML:XMLList;
var GRADIENT_ENTRY:String = "GradientEntry";
entriesXML = fillXML..entries;
if (entriesXML.length()==0) {
entriesXML = fillXML.descendants(GRADIENT_ENTRY);
if (entriesXML.length()==0) {
entriesXML = fillXML.elements(GRADIENT_ENTRY);
}
}
答案 0 :(得分:1)
看起来您必须使用QName对象进行搜索:
var fillXML:XML = <s:LinearGradient rotation="90" xmlns:s="library://ns.adobe.com/flex/spark">
<s:GradientEntry color="0x000000" alpha="0.8"/>
<s:GradientEntry color="0xFFFFFF" alpha="0.8"/>
</s:LinearGradient>;
var entriesXML:XMLList;
var GRADIENT_ENTRY:String = "GradientEntry";
var qname:QName = new QName("library://ns.adobe.com/flex/spark", GRADIENT_ENTRY);
entriesXML = fillXML.elements(GRADIENT_ENTRY);;
if (entriesXML.length()==0) {
entriesXML = fillXML.elements(qname);
}