Java XML Has Child hasOnlyTextChildren( Node node)

Here you can find the source of hasOnlyTextChildren( Node node)

Description

has Only Text Children

License

Open Source License

Declaration

public static boolean hasOnlyTextChildren( Node node) 

Method Source Code


//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;
    }
}

Related

  1. hasElementChildren(Element elemNode)
  2. hasElementChildren(Element elemNode)
  3. hasNamedChild(Element e, String name)
  4. hasNonWhitespaceChildren(Element element)
  5. hasOnlyTextChildNodes(final Node node)
  6. hasTextChildNodesOnly(Node node)