Java Utililty Methods XML Node Text Value

List of utility methods to do XML Node Text Value

Description

The list of methods to do XML Node Text Value are organized into topic(s).

Method

booleanhasNodeText(Node n)
Boolean testing whether or not the node in question is an Element with a single child text node.
return (n.getNodeType() == Node.ELEMENT_NODE && n.hasChildNodes()
        && n.getFirstChild().getNodeType() == Node.TEXT_NODE && n.getFirstChild().equals(n.getLastChild()));
booleanhasOnlyTextSiblings(@Nonnull Node node)
has Only Text Siblings
Node leftSibling = node.getPreviousSibling();
while (leftSibling != null) {
    if (!(leftSibling instanceof Text)) {
        return false;
    leftSibling = leftSibling.getPreviousSibling();
Node rightSibling = node.getNextSibling();
...
booleanhasTextContent(final Node node)
has Text Content
final short nodeType = node.getNodeType();
return nodeType != Node.COMMENT_NODE && nodeType != Node.PROCESSING_INSTRUCTION_NODE;
booleanhasTextContent(Node n)
has Text Content
return (!"".equals(n.getTextContent().trim()) && !" ".equals(n.getTextContent().trim()));