Java tutorial
//package com.java2s; import java.util.Vector; import org.w3c.dom.*; public class Main { public static Vector getElementsByAttribValue(org.w3c.dom.Element element, String attrib, String val) { NodeList desElements = element.getElementsByTagName("*"); Vector selElements = new Vector(desElements.getLength() / 10, 10); for (int i = 0; i < desElements.getLength(); i++) { org.w3c.dom.Node desElement = desElements.item(i); if (desElement.getNodeType() == org.w3c.dom.Element.ELEMENT_NODE) { NamedNodeMap attributeNodes = desElement.getAttributes(); org.w3c.dom.Node selAttribNode = attributeNodes.getNamedItem(attrib); if (selAttribNode != null && selAttribNode.getNodeValue().equalsIgnoreCase(val)) { selElements.add(desElement); } } } return selElements; } }