know if one node of one XMl is empty

X

_XaToA_

hello
with the bellow code i print the XML'nodes values
but i want to know if one node comes empty (<node/>)

how can i know it?
thanks

/code
public void buscar(Node node, int level) {
NodeList listar = node.getChildNodes();
for (int i=0; i<listar.getLength(); i++) {
Node childNode = listar.item(i);
if (level==3 && childNode.getNodeType()==Node.TEXT_NODE) {
System.out.println(childNode.getNodeValue());
}
buscar(childNode, level+1);
}
}
 
W

William Brogden

_XaToA_ said:
hello
with the bellow code i print the XML'nodes values
but i want to know if one node comes empty (<node/>)

how can i know it?
thanks

/code
public void buscar(Node node, int level) {
NodeList listar = node.getChildNodes();
for (int i=0; i<listar.getLength(); i++) {
Node childNode = listar.item(i);
if (level==3 && childNode.getNodeType()==Node.TEXT_NODE) {
System.out.println(childNode.getNodeValue());
}
buscar(childNode, level+1);
}
}

whats wrong with checking the return value of
getFirstChild()
versus null?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,170
Latest member
Andrew1609
Top