I have the XML as below
<Result>
<error><SubTask name="witbe" status="ERROR running Witbe" /></error>
<error><subtask name="VerifyDataServices" status="FAILURE" /></error>
.... multiple error tags
</Result>
I want to retrieve the entire stuff under the error tag no matter what tag is there inside it. I was trying to parse that with XPath but getting null as the value of error
The code I'm using
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
if (null != inputStream)
{
Document doc = db.parse(inputStream);
XPath xPath = XPathFactory.newInstance().newXPath();
String errorTag = "/Result/error";
NodeList nodeList = (NodeList) xPath.compile(errorTag).evaluate(doc, XPathConstants.NODESET);
for (int i = 0; i < nodeList.getLength(); i++) {
System.out.println(nodeList.item(i).getFirstChild().getNodeValue());
}
}
Any idea how to fix this?