Android XML Node Child Check 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 {
    /**//from w w  w. j a  v  a2 s.  c  om
     * 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(Node node, String namespace, String name)
  2. hasTextContent(Node child)
  3. isDescendantOrSelf(Node ctx, Node descendantOrSelf)
  4. isInstance(Node node, String namespace, String name)