This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

want to search XML files for strings

 
majid nakit
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have lot of xml files , they are differents, I have like more than 200 strings in a text file each string in a line, I want to search for these strings patterns in these XML files, please do you have an idea or do you know a code that does that ?
thanks, your help is appreciated.
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The simplest approach would be to treat the files as plain text, and read them line by line and look for the search string. This could be made a lot more efficient by using a search library like Lucene.

If you need precise control over which parts of an XML file are searched, have a look at XQuery, which is a standard for searching XML. One Java implementation is Nux, which sits on top of the excellent XOM library.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic