Thanks for the suggestion Tracy, I will look into that!

--- In flexcoders@yahoogroups.com, "Tracy Spratt" <[EMAIL PROTECTED]> wrote:
>
> You can't convert directly, unless you use
> resultFormat="object"(default), which converts your sml into a nested
> dynamic object structure.  But you have no control over this conversion,
> and it can have some side-effects, particularly with data type
> conversions.
> 
>  
> 
> People often convert xml into an ArrayCollection of strongly typed
> objects, because accessing strongly typed pbjects is significantly
> faster than accessing XML, which this can help performance with very
> large data displays (hundreds of renderers).  You will need to loop over
> the XMLList (xmlData.score), and build the value object items and add
> them to the ArrayCollection manually.
> 
>  
> 
> But, why not simply use XMLListCollection?
> 
> hScores = new XMLListCollection(xmlData.score);
> 
>  
> 
> Tracy
> 
> ________________________________
> 
> From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
> Behalf Of t_singe
> Sent: Sunday, December 30, 2007 12:49 PM
> To: flexcoders@yahoogroups.com
> Subject: [flexcoders] Newbie XML to ArrayCollection Confusion
> 
>  
> 
> I'm hoping someone can help explain how to retrieve an XML doc via
> webservice and then create an ArrayCollection from it. Using the code
> and xml below, I am able to retrieve the xml alright and access the
> nodes, but when I attempt to convert the xml object to an array I end
> up with a single element array. 
> 
> My xml document looks like:
> <?xml version="1.0" encoding="UTF-8" ?> 
> - <scores>
> <score position="1">4</score> 
> <score position="2">1</score> 
> <score position="3">2</score> 
> <score position="4">3</score> 
> <score position="5">5</score> 
> <score position="6">0</score> 
> <score position="7">9</score> 
> <score position="8">6</score> 
> <score position="9">8</score> 
> <score position="10">7</score> 
> </scores>
> 
> My webservice event handler looks like:
> public function hScoresHandler(event:ResultEvent):void {
> var xmlResult:XML ;
> var hScores = new ArrayCollection(); 
> 
> xmlResult = new XML(event.result);
> 
> // This properly outputs the entire XML document
> trace(xmlResult);
> 
> // These properly output the content from different nodes in the
> // XMLM document
> trace("first (0) position: " + xmlResult.score[0]);
> trace("five position: " + xmlResult.score[5]);
> trace("five position: " + [EMAIL PROTECTED]);
> 
> // Convert XML to Array
> hScores = ArrayUtil.toArray(xmlResult);
> 
> // For some reason this outputs a null string
> trace(hScores);
> 
> // Why is the length only one?
> trace("length: " + hScores.length);
> }
>


Reply via email to