Here you can find the source of hasOnlyTextChildren( Node node)
public static boolean hasOnlyTextChildren( Node node)
//package com.java2s; //License from project: Open Source License import org.w3c.dom.*; public class Main { public static boolean hasOnlyTextChildren(/*@Nonnull*/ Node node) { Node childNode = node.getFirstChild(); while (childNode != null) { if (!(childNode instanceof Text)) { return false; }// w ww . j ava2 s .c o m childNode = childNode.getNextSibling(); } return true; } }