4 Replies Latest reply on Jul 28, 2008 12:19 PM by ntsiii

    arraycollection to xmllistcollection

    malachite00
      Is there an easy way to convert an ArrayCollection to an XMLListCollection? I have found plenty of references to convert the reverse, but none that go into an XMLListCollection or XMLList.

      I am receiving a query from a database via a RemoteObject and putting it directly into an ArrayCollection. Some of this data needs to be displayed in a Tree and I've found XMListCollection works better as a data provider. I wrote a method to go through the array and create nodes then add them to the XML, but it seems there would be a way to do this automatically instead. Thanks!
        • 1. Re: arraycollection to xmllistcollection
          g-s-b Level 1
          Well. I would think the best solution would be to change the query results transfer format to XML.

          Unable to do that, when you get the data you need to convert it to an XML object I would think, for the XMLList's source is an XML object.

          Finally, I would re-look at the ArrayCollection as the data provider once more.

          IMHO

          • 2. Re: arraycollection to xmllistcollection
            malachite00 Level 1
            Thanks Greg. I tried casting the query returned from the ColdFusion component to XML, but couldn't get the data into the XMLListCollection this way. When I traced it, all I saw was [object Object] although there were the correct number of entries so I know the right data was going in there. Is there a middle step I need to take to convert the objects into XML?
            • 3. Re: arraycollection to xmllistcollection
              g-s-b Level 1
              I do not use ColdFusion but rather PHP and mySQL usually.
              So I can not really tell you an answer to that.
              For me, I have a PHP class that will return the query results in an XML format. That is what I pass to the application.

              There must be some such options with ColdFusion but I am not the one to ask. :(

              • 4. Re: arraycollection to xmllistcollection
                ntsiii Level 3
                You cannot cast unless the cariable you are casting contains an object of the type you are casting to.

                ArrayCollection will never contain an XMLListcollection, so forget casting.

                If the CFC IS returning xml, then set the resultFormat="e4x", then in the handler, do:
                var xmlResult:XML = XML(event.result);
                trace(xmlResult.toXMLString())

                Tracy