title: How do I loop through result objects in Flex?
body: <p>I am having problems manually looping through xml data that is received via an HTTPService call, the xml looks something like this: </p>
  
  <pre><code>&lt;DataTable&gt;
      &lt;Row&gt;
          &lt;text&gt;foo&lt;/text&gt;
      &lt;/Row&gt;
      &lt;Row&gt;
          &lt;text&gt;bar&lt;/text&gt;
      &lt;/Row&gt;
  &lt;/DataTable&gt;
  </code></pre>
  
  <p>When the webservice result event is fired I do something like this:</p>
  
  <pre><code>for(var i:int=0;i&amp;lt;event.result.DataTable.Row.length;i++)
  {
      if(event.result.DataTable.Row[i].text == "foo")
          mx.controls.Alert.show('foo found!');
  }
  </code></pre>
  
  <p>This code works then there is more than 1 "Row" nodes returned. However, it seems that if there is only one "Row" node then the <em>event.DataTable.Row</em> object is not an error and the code subsequently breaks. </p>
  
  <p>What is the proper way to loop through the <em>HTTPService</em> result object? Do I need to convert it to some type of <em>XMLList</em> collection or an <em>ArrayCollection</em>? I have tried setting the resultFormat to <em>e4x</em> and that has yet to fix the problem...</p>
  
  <p>Thanks.</p>