# AS3 XML trying to create a search feature using Flash

**URL:** <https://forum.kirupa.com/t/as3-xml-trying-to-create-a-search-feature-using-flash/329587>\
**Category:** flash\
**Created:** [September 18, 2012, 5:27pm UTC](https://forum.kirupa.com/t/as3-xml-trying-to-create-a-search-feature-using-flash/329587 "2012-09-18T17:27:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lonestarr](https://avatars.discourse-cdn.com/v4/letter/l/a5b964/32.png) [@lonestarr](https://forum.kirupa.com/u/lonestarr)\
**Post date:** [September 18, 2012, 5:27pm UTC](https://forum.kirupa.com/t/as3-xml-trying-to-create-a-search-feature-using-flash/329587/1 "2012-09-18T17:27:22Z")

</div>

I used the **Using** XML in Flash CS3/AS3 - by kirupa | 17 July 2007, However all you have are trace statements. I am new to AS3 and I am trying to make a search feature using Flash AS3 and XML. I need for the user to be able to enter word in the input box and if found in the xml display the corrosponding location node in a text box. I cannot figuar this out after trying for 3 days. I used this XML:

\<?xml version=“1.0” encoding=“utf-8”?\>

\<Searchfor\>

\<Searchtext Wordlookup=“color”\>  
\<location\>Home Page Overview\</location\>  
\</Searchtext\>

\<Searchtext Wordlookup=“detailed view”\>  
\<location\>Home Page Overview\</location\>  
\</Searchtext\>

\<Searchtext Wordlookup=“individual performance”\>  
\<location\>Home Detailed View\</location\>  
\</Searchtext\>

\<Searchtext Wordlookup=“attendance”\>  
\<location\>Profile Manage Attendance\</location\>  
\</Searchtext\>

\<Searchtext Wordlookup=“add attendance”\>  
\<location\>Profile Manage Attendance\</location\>  
\</Searchtext\>

\</Searchfor\>

and this is what I have for actionscript:

stage.focus = searchTerm\_txt;  
search\_btn.addEventListener(MouseEvent.CLICK, ParseSearchfor)

var xmlLoader:URLLoader = new URLLoader();  
var xmlData:XML = new XML();

xmlLoader.addEventListener(Event.COMPLETE, LoadXML);  
xmlLoader.load(new URLRequest(“xml/searchFor.xml”));

function LoadXML(e:Event):void {  
xmlData = new XML(e.target.data);  
}

function ParseSearchfor(searchtextInput:XML):void {

var searchtextAttributes:XMLList = searchtextInput.Searchtext.attribute(“Wordlookup”);  
var locationList:XMLList = searchtextInput.Searchtext.location;

var usersInput:String = query\_txt.text;  
var locationResults:String = results\_txt. text;

if(usersInput == searchtextAttributes){  
locationResults = locationList;  
}  
else{  
locationResults = “Search can not be found. Check Spelling or enter new search.”;  
}  
}

Will you please help me?

Thank you,  
Romona
