Java tutorial
//package com.java2s; import java.util.ArrayList; import java.util.List; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { public static List<Element> filter(NodeList nl, String attr, String value) { List<Element> result = new ArrayList<Element>(); for (int i = 0; i < nl.getLength(); i++) { Node n = nl.item(i); if (!(n instanceof Element)) { continue; } Element e = (Element) n; if (!value.equals(e.getAttribute(attr))) { continue; } result.add(e); } return result; } }