Here you can find the source of hasChildElements(Element element)
Parameter | Description |
---|---|
element | the element to check. |
public static boolean hasChildElements(Element element)
//package com.java2s; /*--------------------------------------------------------------- * Copyright 2005 by the Radiological Society of North America * * This source software is released under the terms of the * RSNA Public License (http://mirc.rsna.org/rsnapubliclicense) *----------------------------------------------------------------*/ import org.w3c.dom.Element; import org.w3c.dom.Node; public class Main { /**/*from w ww. j a v a 2 s. c o m*/ * Determine whether an element has any child elements. * @param element the element to check. * @return true if the element has child elements; false otherwise. */ public static boolean hasChildElements(Element element) { Node child = element.getFirstChild(); while (child != null) { if (child.getNodeType() == Node.ELEMENT_NODE) return true; child = child.getNextSibling(); } return false; } }