Here you can find the source of hasChild(Node n)
private static boolean hasChild(Node n)
//package com.java2s; /*//from www . ja v a 2 s . c om * Copyright 2010-2011 the original author or authors. * * WebServiceMocker is free software; you can redistribute it and/or modify it under the * terms of version 2.1 of the GNU Lesser General Public License as published by * the Free Software Foundation. * * WebServiceMocker 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 Lesser General Public License for more details at gnu.org. */ import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { private static boolean hasChild(Node n) { NodeList nl = n.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { n = nl.item(i); if (n.getNodeType() == 1) return true; } return false; } }