Here you can find the source of findElementList(String name, String attrName, String attrValue, Document doc)
public static Vector findElementList(String name, String attrName, String attrValue, Document doc)
//package com.java2s; import java.util.Vector; import org.w3c.dom.*; public class Main { /**// w w w . jav a2s . co m * Gets a list of DOM elements with the specified name throughout * the document (not just children of a specific element). */ public static Vector findElementList(String name, Document doc) { return findElementList(name, null, null, doc); } /** * Gets a list of DOM elements with the specified name * that have an attribute with the given name and value. */ public static Vector findElementList(String name, String attrName, String attrValue, Document doc) { if (name == null) return null; Vector v = new Vector(); NodeList list = doc.getElementsByTagName(name); int size = list.getLength(); for (int i = 0; i < size; i++) { Node node = list.item(i); if (!(node instanceof Element)) continue; Element el = (Element) node; if (attrName == null || attrValue == null || attrValue.equals(getAttribute(attrName, el))) { v.add(el); } } return v; } /** * Gets the value of the given DOM element's attribute * with the specified name. */ public static String getAttribute(String name, Element el) { if (name == null || el == null) return null; if (!el.hasAttribute(name)) return null; return el.getAttribute(name); } }