Extracting Node Value from an XML doc.

Hi,

i have an XML doc with the structure

The XML is created dynamically by me using DocumentBuilder

<?xml version="1.0" encoding="UTF-8"?>

<Underl><Code>ABCD</Code></Under>

I need to extract the value from Element Code

I am getting no value when I use the flwg code:

try{

Node firstChildNode=null;

Node secondChildNode=null;

NodeList nodeList = dom.getChildNodes();

for (int i=0; i< nodeList.getLength(); i++){

firstChildNode = nodeList.item(i);

System.out.println("Node Name : " + firstChildNode.getNodeName());

}

NodeList nodeList2 = firstChildNode.getChildNodes();

for (int i=0; i< nodeList2.getLength(); i++){

secondChildNode = nodeList2.item(i);

System.out.println("SECOND Node Name : " + secondChildNode.getNodeName());

String codeExtractedFromXML = secondChildNode.getNodeValue();// Null returned.

}catch(Exception e){

}

Shoudnt getNodeValue() return the value of the node?

[1637 byte] By [bhuru_luthriaa] at [2007-11-27 2:38:34]
# 1
Got it.Thanks,I used getTextContent()works now
bhuru_luthriaa at 2007-7-12 2:59:50 > top of Java-index,Java Essentials,Java Programming...