actionscript 3.0 and e4x: search strings inside an XML object

Find a defined string inside an XML object
// String to Find
var stringToFind:String = "Flash Media";

// XML Object
var myXML:XML =
<order>
<item id='101'>
<title>Technologies</title>
<desc>XML e4x rulez</desc>
</item>

<item id='102'>
<title>Adobe Products</title>
<desc>Flex, Flash, Air, FlashLite, Catalyst, Flash Media Server 2, ... </desc>
</item>


<item id='103'>
<title>Server Side Products</title>
<desc>Flash Media Server 3, Flash Collaborative Service, ColdFustion</desc>
</item>

</order>


// Loop over the XML items
for (var i:uint = 0; i < myXML.item.length(); i++) {

// Get the item description
var tempString:String = myXML.item[i].desc


/*
* Check if the defined word does exist in the description, displaying:
* - Node title
* - Node ID
* - XML node index (from 0 to N)
* - The searched word
*/
if (tempString.search(stringToFind) != -1) {
// This trace displays:
// ---> Adobe Products ( ID - 102 ) contains this word: 'Flash Media' (XML item index: 1 )
// ---> Server Side Products ( ID - 103 ) contains this word: 'Flash Media' (XML item index: 2 )
trace("--->", myXML.item[i].title, "( ID -", myXML.item[i].@id, ") contains this word: '" + stringToFind + "' (XML item index:", i, ")")
}


}

Comments on this post

In recent years Louis Vuitton Handbagsthis inland port city of nearly 300,000Louis Vuitton Handbags people has earned several distinctions, none Chanel Handbagsof them good. Twice atop Forbes'Coach Factory Outlet list of America's Most Miserable Louis Vuitton PursesCities ... Second highest violent-crimeChanel Handbag rate in California ... Second highest home-foreclosure rate Boss Beltsof all major U.S. metro areas. Now, Stockton is on the Coach Factory Onlineverge of another dubious benchmark: bankruptcy.Louis Vuitton Purses In its third straight year of fiscal emergency,Coach Factory Online the city faces a deficit of as high asCoach Factory Outlet $38 million on its $165 million general fundCoach Factory Stores budget. As required by state law,Coach Outlet Store the city
In case you should think Sam was a man, I'd better perhaps tell you he was a pony.Think of me pretending to be a lawyer, and not knowing how to look low enough! The carpet! It had been a stout article in its time, had evidently began http://www.cheap-airjordanshoes.net/ in a drawing-room; then descended to a coffee-room; then gone upstairs altogether to a bedroom.</P><BR/><P>' In my heart I said those words--I have been true to them--I have waited."I have seen your wife--in the spirit, or in the flesh, I know not which--but I have seen her.The priest's loving petition was never forgotten.You shall repeat them, and I will write them down from your dictation."Go then, my dear," said Father Rocco, patting the child on the shoulder; "and come back here to your sister, as soon as you http://www.cheap-airjordanshoes.net/have left the mats.You know the great stones yonder, set up by the heathens; you know the hollow place under the stones they call 'The Merchant's Table'; we had plenty of room to lay him in that, and hide him so; and then http://www.louisvuittonhandbagssell.org/ we ran back to the cottage.The http://www.cheap-airjordanshoes.net/ burden of concealment seemed too heavy to be borne in the presence of the http://www.sellcoachoutlet.net/ priest--and yet, torment as it was, he still bore it! But when he knelt with the rest of the congregation and saw Perrine kneeling by his side--when he felt the calmness of the solemn night and the still sea filling his heart--when the sounds of the first prayers spoke with a dread spiritual language of their own to his soul--then the remembrance of the confession which he had neg lected, and the terror of receiving unprepared the sacrament which he knew would be offered to him--grew too vivid to be endured; http://www.sellcoachoutlet.net/ the sense that he merited no longer, though once worthy of it, the confidence in his perfect truth and candor placed in him by http://www.burberrybags-outlet.net/ the woman with whom he was soon to stand before the altar, overwhelmed him with shame: the mere act of kneeling among that congregation, the passive accomplice by his silence and secrecy, for aught he knew to http://www.louisvuittonsell.org/ the contrary, of a crime which it was his bounden duty to denounce, appalled him as if he had already committed sacrilege that could never be forgiven.

Post a comment

Embed any code between [code] [/code] tags
captcha image   Reload