Here you can find the source of hasChildElements(Element element)
Parameter | Description |
---|---|
element | element that we wanted to know if it has children |
public static boolean hasChildElements(Element element)
//package com.java2s; //License from project: Apache License import org.w3c.dom.NodeList; import org.w3c.dom.Element; import org.w3c.dom.Node; public class Main { /** True if element has children elements @param element element that we wanted to know if it has children @return true if element has children elements *///w w w.j av a 2s.c o m public static boolean hasChildElements(Element element) { NodeList childs = element.getChildNodes(); for (int i = 0; i < childs.getLength(); i++) { Node node = childs.item(i); if (Node.ELEMENT_NODE == node.getNodeType()) { return true; } } return false; } }