2 Replies Latest reply on Mar 18, 2008 3:46 AM by ilanarmi

    xml -> arrayCollection

    michalis0
      Hi, is there an easy way to create an arrayCollection from an XML variable?

      When I use HTTPservice to load an xml file, an arrayCollection is created so
      this should be somehow supported...

      Unfortunatly when I load the xml through a socket as string, I cannot convert
      it easily into an arrayCollection. All my graphs assume arrayCollection, so
      now I am kindof 'lost in translation'...

      TIA
      michael
        • 1. Re: xml -> arrayCollection
          Ivascu Cristian Level 1
          Hi Michael,

          I think that the difference between the two scenarios is that when data comes through via the HTTPService, the SimpleXMLDecoder class is called and used to turn the result into something usable (based on the resultFormat and makeObjectsBindable properties).
          When you load the XML via a socket, the decoder is not called by anyone, so you end up with the raw data on your hands. What you could do is run the output of the socket request through an instance of SimpleXMLDecoder and see if that produces the results you are expecting.

          Cristian
          • 2. Re: xml -> arrayCollection
            ilanarmi
            we an easly converts XML to ArrayCollection
            var myXml:XML = .....;

            var xmlColl:XmlListCollection = new XmlListCollection(myXml);
            var arrColl:ArrayCollection = new ArrayCollection(xmlColl.toArray());