XPath Count function always return 0.0



I'm using below xml to get the count of tag 'c'.



<?xml version='1.0' encoding='UTF-8'?>
<xyz xmlns=".....">
<a>
<b>
<c>X:1 Y:0</c>
<c>X:1 Y:0</c>
<c>X:2 Y:0</c>
</b>
<b>
<c>X:1 Y:0</c>
<c>X:2 Y:0</c>
</b>
</a>
</xyz>


Below is my java code :



xpath = factory.newXPath();
xpr = xpath.compile("count(//xyz/a/b/c)");
System.out.println(xpr.evaluate(inputSource, XPathConstants.NUMBER));


But the above code always returns 0.0


Am I doing something wrong ?


No comments:

Post a Comment