This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Search large xml files

 
Dean Reedy
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I need to do is search XML files which possibly could be as large as 1 mb. I will be searching by allowing the user to type in a word or words and searching the whole xml document for occurences of that word(s). Now I will be searching all the nodes, the attributes as well as the text/data.
Now I have used a xml dom and sax and the searching takes a couple of minutes sometimes.
What is the fastest way to search an xml document? What can I do to speed up my search times.
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DOM of course is going to take a lot of time up front, building a tree in memory. SAX essentially guarantees a method call on every element. Both approaches are predicated on the idea that context is as important as the word you want to find.
If all you really want to do is find a string, don't use either tool. Put the parser tools away, and just use regular expression pattern matching to find it.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18098
50
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
... Or consider an XML-structured DBMS.
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A combination of JDOM with custom data structures to facilitate search/lookup (eg. hashtables ) can perfom a lot better than plain DOM.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic