Here you can find the source of hasElementChildren(Element elemNode)
Parameter | Description |
---|---|
elemNode | a parameter |
public static boolean hasElementChildren(Element elemNode)
//package com.java2s; /*-------------------------------------------------------------------------------- Copyright (C) 2002, 2004 ISOGEN International http://www.isogen.com/*from w w w .j a va 2 s . c o m*/ This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. --------------------------------------------------------------------------------*/ import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.w3c.dom.Element; public class Main { /** * Returns true if the input element has element children. * * @param elemNode * */ public static boolean hasElementChildren(Element elemNode) { NodeList nl = elemNode.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { Node cand = nl.item(i); if (cand.getNodeType() == Node.ELEMENT_NODE) { return true; } } return false; } }