Child node name in a xml

DeeannaAseltine

New Member
I am trying to write a piece of code that can parse any xml and print its contents. I am using DOM parser. I am able to get the name of the root tag of the xml, but cant obtain tag name of the immediate child. This can be done easily in case the node names are known by using the method 'getElementsByTagName' . Is there any way out of this dilemma ?My code goes like this :\[code\]DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();DocumentBuilder db = dbf.newDocumentBuilder();Document doc = db.parse(file);doc.getDocumentElement().normalize();DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();doc.getDocumentElement().getNodeName() // this gets me the name of the root node.\[/code\]Now how can i get the name of the immediate child node so that i can traverse the xml using getElementsByTagName("x").Thanks in advance.
 
Top