Here you can find the source of isSubTagExist(Node node, String tagName)
public static boolean isSubTagExist(Node node, String tagName)
//package com.java2s; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { public static boolean isSubTagExist(Node node, String tagName) { if (node == null) { return false; }//from ww w. j av a2s.c o m NodeList nodeList = node.getChildNodes(); for (int i = 0; i < nodeList.getLength(); i++) { Node n = nodeList.item(i); if (n instanceof Element) { if (((Element) n).getTagName().equals(tagName)) { return true; } } } return false; } }