title: XML HTTPService Result and for each
body: <p>XML is cool in flex, but I have an annoying problem to solve, caused by what I can imagine is a feature. You see, when you have just one tag of something, it creates an object which is not an array. But when finds more than one, it puts it on an array structure.</p>
  
  <p>I want to solve it elegantly. Any recommendation.</p>
  
  <p>Example: this illustrates it, being the result of a HTTP request:</p>
  
  <pre><code>private function initXMLRes(event:ResultEvent):void
  {
      var resObj:Object = event.result;
      //
      for each(var i:Object in resObj.specifictag)
      {
          // to use specifictag attributes, etc. example:
          Alert.show(specifictag.name);
      }
  }
  </code></pre>
  
  <p>The code before will work with 2+ items. It will accept this xml:</p>
  
  <pre><code>&lt;specifictag name="one" /&gt;&lt;specifictag name="two" /&gt;
  </code></pre>
  
  <p>... but not this one:</p>
  
  <pre><code>&lt;specifictag name="one" /&gt;
  </code></pre>
  
  <p>I could check the format of resObj.specifictag (to check if it is has an array) and then duplicate the code (for each case). But -even if it's calling a function- I don't think it is an elegant solution.</p>
  
  <p>Well, I hope someone has a good idea on this matter. (I know from experience that SO has much more C++ experts than flex, but well...)</p>
  
  <p>The perfect thing would be that HTTPrequest handled every tag in a consistent way (using always arrays... though I'm guessing that that would also have its drawbacks).</p>
  
  <p>Thanks!</p>