Here you can find the source of findElement(Element parent, String elementNS, String elementName, String attrName, String attrValue)
public static Element findElement(Element parent, String elementNS, String elementName, String attrName, String attrValue)
//package com.java2s; //License from project: Apache License import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; public class Main { public static Element findElement(Document doc, String elementNS, String elementName, String attrName, String attrValue) {/* w ww . ja v a 2s. c o m*/ return findElement(doc.getDocumentElement(), elementNS, elementName, attrName, attrValue); } public static Element findElement(Element parent, String elementNS, String elementName, String attrName, String attrValue) { NodeList l = parent.getElementsByTagNameNS(elementNS, elementName); for (int i = 0; i < l.getLength(); i++) { Element e = (Element) l.item(i); String val = e.getAttribute(attrName); if (val != null && val.equals(attrValue)) { return e; } } return null; } }