Can somebody find what is wrong with this code. It always returns o nodes no matter whatever XPath I chose
DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
domFactory.setNamespaceAware(true);
domFactory.setIgnoringComments(true);
domFactory.setIgnoringElementContentWhitespace(true);
DocumentBuilder builder = domFactory.newDocumentBuilder();
Document dDoc = builder.parse("P:/MyBooks.xml");
NodeList myNodes = (NodeList) xpath.evaluate("//Title", dDoc, XPathConstants.NODESET);
System.out.println(myNodes.getLength());
MyBookx.xml is:
<?xml version="1.0" encoding="UTF-8"?>
<Books>
<Title attrib="title1"/>
<Title attrib="title2"/>
<Title attrib="title3"/>
</Books>