Java tutorial
//package com.java2s; // License as published by the Free Software Foundation; either import java.util.HashSet; import java.util.Set; import org.w3c.dom.Node; public class Main { public static Set<Node> findElementsByTag(Set<Node> nodes, String tag) { final Set<Node> result = new HashSet<>(); for (Node child : nodes) { if (tag.equals(child.getNodeName())) { result.add(child); } } return result; } }