1 Reply Latest reply on Aug 17, 2006 5:06 PM by krrobert

    HTTP Service XML to ArrayCollection

    Richard_Hughes Level 1
      Hi,
      How do I convert the results from a remote XML List file called using the HTTPService method into an arrayCollection for sorting filtering etc. ??? (I assume it is the arrayCollection please feel free to suggest a better method)

      I have this working by calling the XML as a model that compiles at runtime, it'd be nice to have this work dynamically

      Thanks

      Rich
        • 1. Re: HTTP Service XML to ArrayCollection
          krrobert
          If your data is in XML format, you may want to read it in as XML, and use an XMLList (or XMLListCollection wrapping the XMLList) to do the management of it.

          In terms of how to read it in at runtime (I assume that's what you're asking?) try something along these lines:

          internal var myXMLList:XMLList;

          internal function loadData() : void
          {
          var XML_URL:String = "myData.xml";
          var myXMLURL:URLRequest = new URLRequest(XML_URL);
          var myLoader:URLLoader = new URLLoader();
          myLoader.addEventListener("complete", dataLoaded);
          try
          {
          myLoader.load(myXMLURL);
          } catch(error:Error)
          {
          trace("Failed to load Data");
          }
          }

          internal function dataLoaded(evtObj:Event) : void
          {
          var myLoader:URLLoader = URLLoader(evtObj.target);
          var myXML:XML = XML(myLoader.data);
          myXMLList = myXML.ListedElement;
          }