actionscript 3 - How to search a given string in XML? -


i have xml like:

<bodytext>   <1 beginindex="0" endindex="723">     teddy bear soft toy in form of bear. teddy bears among popular gifts children , given adults signify love, congratulations or sympathy.</1>  <2 beginindex="724" endindex="347">     morris michtom saw drawing of roosevelt , inspired create new toy. created little stuffed bear cub , put in shop window sign read "teddy's bear," after sending bear roosevelt , receiving permission use name.  </2> </bodytext> 

how search particular string in xml ? ex: if user enters "drawing of roosevelt". 2nd xml element contains string , should return 2(it should return paragraph no). how find out ?

convert xml internal class, lets call myentry has id ( 1 , 2 values in example, put them attribute, name of node irrelevant, put "a" ), beginindex, endindex , value (your string) , put method inside myentry in like:

public function search( string:string ):boolean {     return value.indexof( string ) != -1; }  //when search string "drawing of roosevelt": each( var entry:myentry in entries ) {     if( entry.search( string ) )     {        trace( "found!" );        break;     } } 

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -