Java examples for XML:DOM Node
is Empty XML Node
//package com.java2s; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { public static boolean isEmptyNode(Node node) { NodeList nodeList = node.getChildNodes(); for (int i = 0; i < nodeList.getLength(); i++) { Node childNode = nodeList.item(i); if (!childNode.hasChildNodes()) { String value = childNode.getNodeValue(); if (value != null && !value.isEmpty()) { return false; }//w ww . j a va 2 s. c o m } else { if (!isEmptyNode(childNode)) { return false; } } } return true; } }