I am using following code to get values of a particular tag in xml:
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
Document doc = null;
DocumentBuilder docbuilder = docBuilderFactory.newDocumentBuilder();
doc = docbuilder.parse(jobFilePath);
NodeList nodeList = doc.getElementsByTagName("xyz");
System.out.println("nodelist Lengthhhhhhhhhh = " + nodeList.getLength());
for (int i=0;i<nodeList.getLength();i++) {
Node c= nodeList.item(i);
System.out.println("val =" + c.getNodeValue());
}
input xml is
<abc>
<xyz p="Layouts">a</xyz>
<xyz p="Layouts">b</xyz>
<xyz p="Layouts">3</xyz>
</abc>
Output is
nodelist Lengthhhhhhhhhh 3
val = null
val = null
val = null
why is it coming out null?