6 Replies Latest reply on Mar 20, 2008 7:08 AM by ilanarmi

    iterate over an XML

    kilyas2007 Level 1
      Well I can successfully iterate through a simple xml as follows:-

      var myXML:XML = <company>
      <department>IT</department>
      <department>Accounts</department>
      <department>HR</department>
      </company>;

      for each (var item in myXML.department)
      {
      trace(item);
      }
      /* output
      IT
      Accounts
      HR
      */


      however I am a little confused about what if the XML is nested as follows:-

      var myXML:XML = <company>
      <department name="IT">
      <department name="R&D"></department>
      <department name="Systems"></department>
      <department name="Testing & QA"></department>
      </department>
      <department name="Accounts"></department>
      <department name="HR"></department>
      </company>;


      how should I proceed in such a case.