dcsimg

How can I check with the DOM-API, if a tag is empty (<mytag/>) or not (<mytag>data</mytag>)?

Davanum Srinivas

Element element = ....;
String  nodeValue = element.getNodeValue();
if(nodeValue==null||nodeValue.length()==0)
    System.out.println("Element is empty");
else
    System.out.println("Element value:" + nodeValue);