Hi
the following is the code snippet where I am obtaining a NodeList and then passing the nodelist to another xpath evaluate function.
I am not able to execute the xpath expression on the node list. Can you please tell me what could be the error...
The code and XML file are as below...
String xpathExpr = "/library/country/books";
NodeList nlist = (NodeList)xpathEvaluator.evaluate(xpathExpr, w3cdom, XPathConstants.NODESET);
xpathExpr = "/books/book/title";
String value = (String)xpathEvaluator.evaluate(xpathExpr, nlist, XPathConstants.STRING)
System.out.println("VALUE ==== " + value);
<?xml version="1.0" encoding="UTF-8"?>
<library>
<country>
<books>
<book type="hardback" lang="EN">
<title>Atlas & Shrugged</title>
<author>Ayn Rand</author>
<isbn>0525934189</isbn>
<price>39.95</price>
</book>
<book type="paperback" lang="JP">
<title>A Burnt-Out Case</title>
<author>Graham Greene</author>
<isbn>0140185399</isbn>
<price>13.00</price>
</book>
</books>
</country>
<country>
<books>
<book type="hardback" lang="EN">
<title>Atlas & Shrugged</title>
<author>Ayn Rand</author>
<isbn>0525934189</isbn>
<price>39.95</price>
</book>
<book type="paperback" lang="JP">
<title>A Burnt-Out Case</title>
<author>Graham Greene</author>
<isbn>0140185399</isbn>
<price>13.00</price>
</book>
</books>
</country>
</library>
Thanks.