Skip navigation
Currently Being Moderated

Error1009 when convert XMLList to XMLListCollection

Aug 16, 2013 2:18 AM

Tags: #1009 #xmllistcollection

I want to convert a XML to ArrayCollection. So I convert the XML to XMLList, then XMLList to XMLListCollection, then XMLListCollection to Array, and finally Array to ArrayCollection. Please see my code below:


var nodexml:XML;

                                        var searchData:XMLList;

                                        var countriesXML: XMLListCollection;

                                        var countriesArray:Array;

var sourceModel:ArrayCollection;

                                        nodexml= new XML(;

                                        searchData = new XMLList(nodexml.elements("node"));

                                        countriesXML= new XMLListCollection(searchData);

                                        countriesArray = new Array(countriesXML.toArray());

                                        sourceModel= new ArrayCollection(countriesArray);


my sample XML is as below:









Error 1009 occurs in this statement:  countriesXML= new XMLListCollection(searchData);


I tried many times and I don't know how to solve this issue. I insert watch expressions and found no data is read in this statement. the previous two statements run successfully.


Could anyone help me out for this? Thanks a million in advance!

  • Currently Being Moderated
    Aug 16, 2013 7:43 AM   in reply to Anne0829




                                            searchData = nodexml.elements("node");


    Accessing XML generally returns an XMLList.


    If that doesn't work, post the full text of the error including stack trace.



    Mark as:
  • Currently Being Moderated
    Aug 18, 2013 10:56 PM   in reply to Anne0829

    What is countries.length?  Is it 0 or the right number?


    Your XML has text elements in the node elements, and Flex DataGrids and maybe other components won't handle that very well.



    Mark as:
  • Currently Being Moderated
    Aug 18, 2013 11:20 PM   in reply to Anne0829

    DataGrid expects the items to have name/value pairs.  There isn't a "name" for the text node.  You can probably  use a labelFunction to extract the text node.

    Mark as:
  • Currently Being Moderated
    Aug 19, 2013 6:31 AM   in reply to Anne0829

    When discussing errors, it is best to post the entire text of the error including stack traces.  That information is often helpful.


    My guess is that item is not a String so you can't use (item as String) and should use item.toString() instead.

    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points