Java XML Has Child hasChildElement(NodeList list)

Here you can find the source of hasChildElement(NodeList list)

Description

Checks if the given NodeList contains a child element.

License

Open Source License

Parameter

Parameter Description
list The NodeList to check.

Return

Whether the contains children.

Declaration

public static boolean hasChildElement(NodeList list) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    /**//ww  w  .  j a va  2s.  com
     * Checks if the given {@link NodeList} contains a child element.
     *
     * @param list The {@link NodeList} to check.
     * @return Whether the {@link NodeList} contains children.
     */
    public static boolean hasChildElement(NodeList list) {

        Node n;

        for (int i = 0; i < list.getLength(); i++) {
            n = list.item(i);

            if (n.getNodeType() == Node.ELEMENT_NODE) {
                return true;
            }
        }

        return false;

    }
}

Related

  1. hasChild(Element root, String childName)
  2. hasChild(Element start, String name)
  3. hasChild(Node n)
  4. hasChildElement(Element elem, String namespace, String localName)
  5. hasChildElement(Element element, String name)
  6. hasChildElement(TreeWalker walker)
  7. hasChildElementNodes(@Nonnull final Node aStartNode)
  8. hasChildElements(Element element)
  9. hasChildElements(Element element)