Core/src/main/java/org/openestate/io/core/XmlUtils.java
public static void clean(Node node) {
        NodeList childNodes = node.getChildNodes();
        for (int n = childNodes.getLength() - 1; n >= 0; n--) {
            Node child = childNodes.item(n);
            short nodeType = child.getNodeType();
            if (nodeType == Node.ELEMENT_NODE) {
                XmlUtils.clean(child);
            } else if (nodeType == Node.COMMENT_NODE) {
                node.removeChild(child);
            } else if (nodeType == Node.TEXT_NODE) {
                String value = StringUtils.trimToNull(child.getNodeValue());
                if (value == null)
                    node.removeChild(child);
                else
                    child.setNodeValue(value);
            }
        }
    }
public static void clean(Node node) {
        NodeList childNodes = node.getChildNodes();
        for (int n = childNodes.getLength() - 1; n >= 0; n--) {
            Node child = childNodes.item(n);
            short nodeType = child.getNodeType();
            if (nodeType == Node.ELEMENT_NODE) {
                XmlUtils.clean(child);
            } else if (nodeType == Node.COMMENT_NODE) {
                node.removeChild(child);
            } else if (nodeType == Node.TEXT_NODE) {
                String value = StringUtils.trimToNull(child.getNodeValue());
                if (value == null)
                    node.removeChild(child);
                else
                    child.setNodeValue(value);
            }
        }
    }
Recursively remove any comments and unnecessary white spaces from a
{@link Node} and its children.

@param node the node to clean