3 Replies Latest reply on Dec 18, 2006 10:00 PM by bhleonard

    e4x XML selecting node problem

    Camus Miu
      var foodgroup:XML = <foodgroup>
      <fruits>
      <fruit color="red">Apple</fruit>
      <fruit color="orange">Orange</fruit>
      <fruit color="green">Pear</fruit>
      <fruit color="red">Watermelon</fruit>
      </fruits>
      <fruits>
      <fruit color="yellow">Pineapple</fruit>
      <fruit color="orange">Orange</fruit>
      <fruit color="green">Pear</fruit>
      <fruit color="red">Watermelon</fruit>
      </fruits>
      </foodgroup>;

      trace( foodgroup..fruits.(fruit[0]=="Pineapple"));

      // Displays:
      <fruits>
      <fruit color="yellow">Pineapple</fruit>
      <fruit color="orange">Orange</fruit>
      <fruit color="green">Pear</fruit>
      <fruit color="red">Watermelon</fruit>
      </fruits>

      trace( foodgroup..fruits.(fruit=="Pineapple"));
      // Displays nothing

      Can I use the attribute color="yellow" and fruit=Pineapple to select the <fruits> node
      instead of using fruit[0]=Pineapple ???