开发者

How to convert XmlList to ArrayList

I have this xml file.

var xml:XML =   <rootNode>
        开发者_开发知识库    <element name="CompositeFont">
                  <attribute name="Self">
                    <data type="string"/>
                  </attribute>
                  <element name="Font">
                  </element>        
            </element>
    </rootNode>;

I am getting XmlList of this xml by using

 var elementList:XMLList = xml.children();

But I want these node names, example: element,attribute,element in arrayList.

["element","attribute","element"]

Please, help........ Thanks.:)


Since XmlList directly inherits Object (opposed to IList), you will have to loop over it an add each item to a new ArrayCollection.

var ac:ArrayCollection = new ArrayCollection();
for each ( var xml:XML in elementList ) {
    ac.addItem(xml);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜