Java API for XML (JAXP) – XPath

XPath and JAXP

XPath is a language for querying XML Documents. Using a certain syntax XPath can retrieve specific node or list of nodes from the XML Document. This tutorial does not explain XPath syntax but shows how to use JAXP to implement XPath querying. The Steps for XPath querying are:

  • Obtain the XPath class from XPathFactory. This class provides the environment for querying the XML DOM Document using an XPath expression
  • Create the XPath expression String
  • Evaluate the XPath expession using the XPath class, the DOM Document and the Xpath expression

Here’s an example that demonstrates it all.

Java API for XML (JAXP) – XPath

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to top