Use regular repression to filter tag value : Filter « XML « Flash / Flex / ActionScript






Use regular repression to filter tag value

 

package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){

        var fruits:XML = <fruits>
                           <fruit color="red">
                             <name>Apple</name>
                           </fruit>
                           <fruit color="orange">
                             <name>Orange</name>
                           </fruit>
                           <fruit color="green">
                             <name>Pear</name>
                           </fruit>
                           <fruit color="red">
                             <name>Watermelon</name>
                           </fruit>
                         </fruits>;
        trace( fruits.fruit.( /^[aeiouAEIOU].*/.test( name ) ) );

    }
  }
}

        








Related examples in the same category

1.Filtering XML Data
2.Returns a list of employees with a salary less than or equal to $35,000.
3.Returns a list of employees with a salary between $35,000 and $50,000:
4.Returns a list of the designers in the company:
5.A list of employees whose ID number is 238
6.Retrieve a list of employees hired in the year 2004
7.Searching XML