XPath is a query language designed for querying XML documents. For example, a simple XPath query that finds the titles of all the books in a document whose author is Sandeep JOshi might look like this:
//book[author="Sandeep Joshi"]/title
it is possible to integrate XPath into Java programs so that you get the best of both worlds: Java for what Java is good for and XPath for what XPath is good for.Java 5 introduced the javax.xml.xpath package to provide an engine and object-model independent XPath library.
Next you create an XPathFactory:
XPathFactory factory = XPathFactory.newInstance();
You then use this factory to create an XPath object:
XPath xpath = factory.newXPath();
The XPath object compiles the XPath expression:
XPathExpression expr = xpath.compile("//book[author="Sandeep Joshi"]/title");
Advantages of using XPATH:
1). XPath is simple to use and more effective then the conventional XML mining programs.
2). XPATH can be used in XSLT, Java.
3). XPATH offers wide range of patterns to choose from
4). Vast number of online resources are available for XPATH. Some are:
www.w3schools.com/Xpath
www.ibm.com/developerworks/library/x-javaxpathapi.html