jQuery in Action, 3rd edition
The moose likes XML and Related Technologies and the fly likes XML Filtering using XPath Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XML Filtering using XPath" Watch "XML Filtering using XPath" New topic

XML Filtering using XPath

Eurig Jones
Ranch Hand

Joined: Feb 05, 2008
Posts: 57

I have a problem to solve. I need to filter very large XML documents using XPath. I need to provide a list of xpaths to generate a smaller versions of the documents. for example...

Input:XPathOutput:What is a good way to do this using Java APIs?

William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13018
If your input XML document is truly "very large" - too large to get in memory as a DOM - the standard library XPath will not help you because it requires a DOM to work with.

For documents too big for DOM, you are stuck with some form of SAX or StAX parsing.

I found Harold's chapter on SAX filters to be very helpful when thinking about big SAX problems.

You might find the servingXML toolkit to be helpful.

Shane Lee
Ranch Hand

Joined: Mar 19, 2005
Posts: 63
How large an xml file william are we talking before looking into streaming xml instead of parsing as a DOM and using xpath and xquery to query the data?
I agree. Here's the link: http://aspose.com/file-tools
subject: XML Filtering using XPath
It's not a secret anymore!