-
Bug
-
Resolution: Fixed
-
P4
-
6
-
b64
-
sparc
-
solaris_10
The following example in the package docs for javax.xml.xpath:
XPath xpath = XPathFactory.newInstance().newXPath();
String expression = "/widgets/widget";
InputSource inputSource = new InputSource("widgets.xml");
NodeSet nodes = (NodeSet) xpath.evaluate(expression, inputSource, XPathConstants.NODESET);
is incorrect. The return value of xpath.evaluate should be cast to a NodeList, not a
NodeSet. Fix is:
XPath xpath = XPathFactory.newInstance().newXPath();
String expression = "/widgets/widget";
InputSource inputSource = new InputSource("widgets.xml");
NodeList nodes = (NodeList) xpath.evaluate(expression, inputSource, XPathConstants.NODESET);
XPath xpath = XPathFactory.newInstance().newXPath();
String expression = "/widgets/widget";
InputSource inputSource = new InputSource("widgets.xml");
NodeSet nodes = (NodeSet) xpath.evaluate(expression, inputSource, XPathConstants.NODESET);
is incorrect. The return value of xpath.evaluate should be cast to a NodeList, not a
NodeSet. Fix is:
XPath xpath = XPathFactory.newInstance().newXPath();
String expression = "/widgets/widget";
InputSource inputSource = new InputSource("widgets.xml");
NodeList nodes = (NodeList) xpath.evaluate(expression, inputSource, XPathConstants.NODESET);
- duplicates
-
JDK-6251227 Package Overview for javax.xml.xpath has error in example code
-
- Closed
-