Here you can find the source of hasChild(Element parent, String nodeName)
public static boolean hasChild(Element parent, String nodeName)
//package com.java2s; //License from project: Open Source License import org.w3c.dom.Element; import org.w3c.dom.NodeList; public class Main { public static boolean hasChild(Element parent, String nodeName) { NodeList childNodes = parent.getChildNodes(); int length = childNodes.getLength(); for (int i = 0; i < length; i++) if (childNodes.item(i).getNodeName().equals(nodeName)) return true; return false; }/*ww w .j a va 2 s. c o m*/ }