Can someone tell me how to read this kind of XML file to get the child element names?
<CEB>
<MOREVALUES></MOREVALUES>
</CEB>
<DILOG>
<MOREVALUES></MOREVALUES>
</DILOG>
<MOBITLE>
<MOREVALUES></MOREVALUES>
</MOBITLE>
e.g I want to read all the child tags inside the <CTLBILL> tag. <CEB>, <DILOG>, and <MOBITLE> in this case.
This doesn't work:
public static void getTags() {
try {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(new File("C:\\ctlbill.xml"));
NodeList nodeLst = doc.getChildNodes();
for (int s = 0; s < nodeLst.getLength(); s++)
{
}
} catch (Exception e) {
e.printStackTrace();
}
}