Here you can find the source of hasNodeText(Node n)
public static boolean hasNodeText(Node n)
//package com.java2s; import org.w3c.dom.Node; public class Main { /**//from w w w . jav a 2s. co m Boolean testing whether or not the node in question is an Element with a single child text node. */ public static boolean hasNodeText(Node n) { return (n.getNodeType() == Node.ELEMENT_NODE && n.hasChildNodes() && n.getFirstChild().getNodeType() == Node.TEXT_NODE && n.getFirstChild().equals(n.getLastChild())); } }