Java tutorial
//package com.java2s; /*L * Copyright SAIC, Ellumen and RSNA (CTP) * * * Distributed under the OSI-approved BSD 3-Clause License. * See http://ncip.github.com/national-biomedical-image-archive/LICENSE.txt for details. */ import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { public static boolean isElementNodeExist(Node root, String nodeString) { NodeList nlist = root.getChildNodes(); for (int i = 0; i < nlist.getLength(); i++) { if (nlist.item(i) instanceof Element) { if (nlist.item(i).getNodeName().equalsIgnoreCase(nodeString)) { return true; } if (nlist.item(i).hasChildNodes() && isElementNodeExist(nlist.item(i), nodeString)) { return true; } } } return false; } }