1 Reply Latest reply on Oct 6, 2009 12:07 PM by Starlover_jacob

    reverse xml order

    Starlover_jacob Level 1

      Hi there,


      For some reason i need to reverse my xml.

      Now i tried creating an array from my xml and do myarray.reverse();


      like this:

      var list:XMLList=new XMLList(myXML);

      var xmlColl:XMLListCollection = new XMLListCollection(list);
      var arrColl:Array = new Array(xmlColl.toArray());



      but this did not reverse my xml..


      so my question;

      How do i reverse xml?


      my xml:


           <item title="a" description="link"></item>

           <item title="b" description="link"></item>

           <item title="c" description="link">

                <item title="d" description="link"></item>

                <item title="e" description="link"></item>


           <item title="f" description="link"></item>




        • 1. Re: reverse xml order
          Starlover_jacob Level 1

          i figured it out.. if it is the correct way i dont know, but it works for me.


          public var myXML:XML;
          public var newxml:XML;
          private function init():void
               <item title="a" description="http://mylinka.html"></item>
               <item title="b" description="http://mylinkb.html"></item>     
               <item title="c" description="http://mylinkc.html" >
                    <item title="d" description="http://mylinkd.html" ></item>
                    <item title="e" description="http://mylinke.html"></item>
                    <item title="f" description="http://mylinkf"></item>
               <item title="g" description="http://mylinkg.html">
                    <item title="h" description="mylinkh"></item>
                    <item title="i" description="mylinki"></item>
          var temparr:Array=new Array();
          for each(var element:XML in myXML.elements())
          var xmlstring:String= "<item></item>";
          newxml=new XML(xmlstring);
          for (var i:uint=0; i<temparr.length; i++)

          Add a watch expression on newxml and you will see the xml is in reverse order.


          Greets, Jacob