JXPath is a java library for Object Graph Navigation using the XPath syntax.
This requires the libraries commons-jxpath-1.3.jar, commons-beanutils.jar and commons-logging.jar to be in classpath.
The following example shows how to modify nested properties in JXPath.
/**
* @param args
*/ public static void main(String[] args) {
BookStore bookStore = new BookStore(
Arrays.asList( new Book("A1", 11.11, new Author("X1")), new Book("B2", 22.22, new Author("X2")), new Book("C3", 33.33, new Author("X3")), new Book("D4", 44.44, new Author("X4"))
)
);
//Create JXPathContext with BookStore instance as ROOT node
JXPathContext context = JXPathContext.newContext(bookStore);
context.setValue("/books[@title='B2']/price", 1000);
context.setValue("/books[@title='B2']/author/email", "[email protected]");