[flash8] speeding up XML string searches

Hi everyone, this is my first time posting here so bear with me if this post is a little long winded, i just want to clearly get across my question. also, props are due to kirupa.com cause this site is indispensable - i’ve definitely used this site for reference many many times before!

anyway getting to the point…

so i’m trying to implement a string search of an XML document that is pretty huge (a directory with ~15,000 entries), and i want to implement search functionality similar to iTunes. This means that when the user begins typing into the search field it automatically updates the results as he/she is typing. The problem arises with the amount of time it takes to return results for single letter searches and other such general searches - for example when i search for “z” it takes a prohibitively long time to execute and i get a dialog box asking me if i want to stop the script. This is a basic rundown of how i’m running the search (its pretty primitive, i’ve basically created this as a test to see how fast flash can search large XML documents):

  • i have load an external XML document into an XML object in flash

  • the XML data is set up so that each entry is a node, and all information for each entry is stored in attributes (i.e. <root><entry name=“villa, bob” phone=“8005552222”></entry><entry name=“antoinette, mary”… etc.)

  • i use a for loop to go through each node and use the String.indexOf() method to find out if there is a search criteria match in each XML attribute, and if there is a list them in a text field

Does anyone have any tips on how to speed up my search? Is it an XML issue or is it a String search using indexOf() issue? I’ve read about using XPathAPI but haven’t tried it yet, but i suspect that my problem is more to do with the String searching. Are there more efficient ways to search strings? And what are some ways to speed up XML interaction in flash, in respect to searching?

Thanks so much in advance, I have a big project coming up depending on this and I’m struggling to find any kind of documentation on this.

killjoyboy