Hi,
I wanted to get Child node names from the below XML file. I am using DOM parser for reading the XML file in my program. Please help me. Just I need the child node name of employee node like firstname and Lastname.
<company>
<employee>
<firstname>priya</firstname>
<lastname>mantra</lastname>
</employee>
</company>
NodeList nodeLst = doc.getElementsByTagName("employee");
for (int s = 0; s < nodeLst.getLength(); s++) {
Node fstNode = nodeLst.item(s);
if (fstNode.getNodeType() == Node.ELEMENT_NODE) {
Element fstElmnt = (Element) fstNode;
NodeList fstNmElmntLst =fstElmnt.getElementsByTagName("firstname");
In the above code, I dont want to Hardcode the String firstname and wanted to send from the list of one of the child node. I don't see any method called getName().
Thank you
coolguy
Edited by: coolguy on Feb 18, 2008 6:01 AM