Sachin J
Sachin J

Reputation: 2201

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.:)

Upvotes: 0

Views: 1940

Answers (1)

Matt MacLean
Matt MacLean

Reputation: 19656

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);
}

Upvotes: 3

Related Questions