File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes want to search XML files for strings Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "want to search XML files for strings" Watch "want to search XML files for strings" New topic

want to search XML files for strings

majid nakit
Ranch Hand

Joined: Jun 26, 2001
Posts: 167
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

Joined: Mar 22, 2005
Posts: 42959
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.
I agree. Here's the link:
subject: want to search XML files for strings
It's not a secret anymore!