Java XML Has Child hasChildElements(Node node)

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

Description

True if the node has child elements.

License

Apache License

Declaration

public static boolean hasChildElements(Node node) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class Main {
    /** True if the node has child elements. */
    public static boolean hasChildElements(Node node) {
        NodeList nlist = node.getChildNodes();
        for (int i = 0; i < nlist.getLength(); i++) {
            Node child = nlist.item(i);
            if (child.getNodeType() == Node.ELEMENT_NODE)
                return true;
        }/*from ww w.j  a  v a  2 s.  c  o m*/
        return false;
    }
}

Related

  1. hasChildElementNodes(@Nonnull final Node aStartNode)
  2. hasChildElements(Element element)
  3. hasChildElements(Element element)
  4. hasChildElements(Element element)
  5. hasChildElements(Node node)
  6. hasChildElements(Node node)
  7. hasChildElements(Node node)
  8. hasChildElementWithAttribute(Element element, String attributeName, String attributeValue)
  9. hasChildNode(Element root, String childNodeName)