1 Reply Latest reply on Mar 24, 2011 11:38 AM by Flex harUI

    XML E4X matching on attribute value


      I am sure this was asked before.  I even found a thread, but it just linked to another thread, and the link didn't work.


      I am having a problem matching elements by attribute value:


      var xml1:XML =


        <Player Number="25" Position="P"/>

        <Player Number="12" Position="C"/>

        <Player Number="16" Position="1B"/>

        <Player Number="3" Position="2B"/>

        <Player Number="31" Position="3B"/>

        <Player Number="11" Position="SS"/>

        <Player Number="2" Position="LF"/>

        <Player Number="14" Position="CF"/>

        <Player Number="29" Position="RF"/>



      var _gteq25:XMLList = xml1.Player.(@Number>=25);

      trace(">=25  begin");


      trace(">=25  end");


      var _eq25:XMLList = xml1.Player.(@Number==25);

      trace("==25  begin");


      trace("==25  end");



      >=25  begin

      <Player Number="25" Position="P"/>

      <Player Number="31" Position="3B"/>

      <Player Number="29" Position="RF"/>

      >=25  end

      ==25  begin

      ==25  end



      Why doesn't the equality condition match against "25"?  I tried with quotes and without.  I have tried this by matching by @Position as well, and no luck.


      I'd rather not write a loop for this.  I know that's all that is happening internally; but it is so much cleaner if the e4x parser does the work for me.