开发者

How to convert XmlList to ArrayList

开发者 https://www.devze.com 2023-04-12 04:49 出处:网络
I have this xml file. var xml:XML =<rootNode> 开发者_开发知识库<element name=\"CompositeFont\">

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

精彩评论

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