If you Google “Java XPath” this is one of the first articles returned. Clear and concise explanation for how to use the API:
XPath expressions are much easier to write than detailed Document Object Model (DOM) navigation code. When you need to extract information from an XML document, the quickest and simplest way is to embed an XPath expression inside your Java program. Java 5 introduces the javax.xml.xpath package, an XML object-model independent library for querying documents with XPath.
via The Java XPath API.