4 Replies Latest reply on Apr 3, 2009 11:55 AM by Newsgroup_User

    xml to ArrayCollection

    SiHoop Level 1
      I'm trying to convert xml to an ArrayCollection and have found some sample code that explains how to do this, but the code appears to fail. Can anyone point me to code that will convert the xml properly? My xml file contains the following :
      <?xml version="1.0" encoding="windows-1252" ?>
      <TABLE>
      <EXAMPLE1>
      <difficulty> 300 </difficulty>
      <N> 184 </N>
      <discrimination> 200 </discrimination>
      <item> 1 </item>
      </EXAMPLE1>
      <EXAMPLE1>
      <difficulty> 100 </difficulty>
      <N> 184 </N>
      <discrimination> 0.38416239 </discrimination>
      <item> 2 </item>
      </EXAMPLE1>
      <EXAMPLE1>
      <difficulty> 533 </difficulty>
      <N> 184 </N>
      <discrimination> 0.51260614 </discrimination>
      <item> 3 </item>
      </EXAMPLE1>
      <EXAMPLE1>
      <difficulty> 233 </difficulty>
      <N> 184 </N>
      <discrimination> 0.2515222 </discrimination>
      <item> 4 </item>
      </EXAMPLE1>
      </TABLE>

      I found the link at: Link
      Below is the code I used to try to convert the xml:
        • 1. Re: xml to ArrayCollection
          Peter Hahmann Level 1
          You'll need to loop through your xml, create your objects and add them to your ArrayCollection. If you show me how your ArrayCollection should look line I can provide you the code.

          Regards,
          Peter
          • 2. Re: xml to ArrayCollection
            SiHoop Level 1
            I'm attempting to modify existing code where the arrayCollection looks like the following:
            [Bindable]
            public var myRuns1:ArrayCollection = new ArrayCollection([
            {day:"10/13", run:1000, goal:1200, time:"8:45am", miles:3.5, runTime:"0:47:25", pace:"6:23", cal:526},
            {day:"10/14", run:1500, goal:2000, time:"8:50am", miles:5.5, runTime:"0:47:27", pace:"6:23", cal:526}]);
            • 3. Re: xml to ArrayCollection
              Peter Hahmann Level 1
              Your xml does not contain the same data as the one you are showing me in the Collection. Now what?

              Regards,
              Peter
              • 4. Re: xml to ArrayCollection
                Level 7

                "SiHoop" <webforumsuser@macromedia.com> wrote in message
                news:gr3ofu$1ql$1@forums.macromedia.com...
                > I'm trying to convert xml to an ArrayCollection and have found some sample
                > code
                > that explains how to do this, but the code appears to fail. Can anyone
                > point me
                > to code that will convert the xml properly? My xml file contains the
                > following :

                I think that XMLListCollection has a method to convert it to an Array or
                ArrayCollection ( I forget which).

                However, why not just use the XMLListCollection? As long as the fields are
                the same, it should still work.