Java tutorial
//package com.java2s; //License from project: Apache License import org.w3c.dom.Node; public class Main { /** Decide if the node is text, and so must be handled specially */ public static boolean isTextNode(final Node n) { if (n == null) { return false; } short nodeType = n.getNodeType(); return nodeType == Node.CDATA_SECTION_NODE || nodeType == Node.TEXT_NODE; } }