Java examples for XML:XML Element Child
Check if XML Element has Child
//package com.java2s; 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; }//from www . j av a 2s . co m }