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);
}