private boolean containsOnlySpaces(Node currentNode)
    {
        boolean result = true;
        if (currentNode.getNodeType() == Node.TEXT_NODE) {
            Text textNode = (Text) currentNode;
            if (textNode.getNodeValue().trim().length() > 0) {
                result = false;
            }
        } else if (currentNode.getNodeType() != Node.COMMENT_NODE) {
            result = false;
        }
        return result;
    }
private boolean containsOnlySpaces ( Node currentNode ) { boolean result = true ; if ( currentNode . getNodeType ( ) == Node . TEXT_NODE ) { Text textNode = ( Text ) currentNode ; if ( textNode . getNodeValue ( ) . trim ( ) . length ( ) > 0 ) { result = false ; } } else if ( currentNode . getNodeType ( ) != Node . COMMENT_NODE ) { result = false ; } return result ; }
@param currentNode the current node to check
@return false if the current node contains something other than whitespaces or newlines, true otherwise