Java tutorial
//package com.java2s; //License from project: Apache License import org.w3c.dom.Node; public class Main { /** * @param n Node to look under * @return true if the given node contains any #text children */ public static boolean isTextNode(Node n) { for (Node ele = n.getFirstChild(); ele != null; ele = ele.getNextSibling()) { String name = ele.getNodeName(); if (!name.equalsIgnoreCase("#text")) return false; } return true; } }