12.1. Obtaining Commons JXPath

Problem

You need to use Jakarta Commons JXPath to select objects from a Collection using XPath syntax.

Solution

You must download the latest version of Commons JXPath, and place the Commons JXPath JAR in your project’s classpath. Following the steps outlined in Recipe 1.1, download Commons JXPath 1.2 instead of Commons Lang.

Discussion

Commons JXPath provides a mechanism for evaluating XML Path Language (XPath) expressions against objects and various data structures in Java. This unconventional application of XPath to objects enables a developer to traverse, address, and filter specific nodes or locations in a complex object graph. This chapter details a few of the ways in which JXPath can be used to search, select, and filter objects.

If you have a Maven project that needs to use Commons JXPath, add a dependency on Commons JXPath 1.2 with the following section in project.xml:

<dependencies>
  <dependency>
    <id>commons-jxpath</id>
    <version>1.2</version>
  </dependency>
  ....other dependencies...
</dependencies>

See Also

For more information about Commons JXPath, see the Commons JXPath project page at http://jakarta.apache.org/commons/jxpath. For more information about XPath, see the official W3C XPath recommendation at http://www.w3.org/TR/xpath.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.12.11