Here you can find the source of hasElementChildren(Element element)
Parameter | Description |
---|---|
element | a parameter |
public static boolean hasElementChildren(Element element)
//package com.java2s; /*/*w w w . ja va 2s. c o m*/ * Copyright (c) 2012. betterFORM Project - http://www.betterform.de * Licensed under the terms of BSD License */ import org.w3c.dom.*; public class Main { /** * just the same as hasNonWhitespaceChildren, but seen from a different perspective ;) * * @param element * @return true, if any Element nodes are found, otherwise false */ public static boolean hasElementChildren(Element element) { return hasNonWhitespaceChildren(element); } /** * check, if the passed element node has non-whitespace children. * * @return true, if any Element nodes are found, otherwise false */ public static boolean hasNonWhitespaceChildren(Element element) { if (element.hasChildNodes()) { NodeList children = element.getChildNodes(); int len = children.getLength(); Node n = null; for (int i = 0; i < len; i++) { n = children.item(i); if (n.getNodeType() == Node.ELEMENT_NODE) { return true; } } return false; } else { return false; } } }