Java tutorial
//package com.java2s; import java.util.ArrayList; import java.util.Iterator; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { @SuppressWarnings("unchecked") public static Iterator getElementsByTagName(Element element, String tag) { ArrayList<Element> children = new ArrayList<Element>(); if (element != null && tag != null) { NodeList nodes = element.getElementsByTagName(tag); for (int i = 0; i < nodes.getLength(); i++) { Node child = nodes.item(i); // System.out.println("Name: " + child.getNodeName() + ", Value: " + child.getFirstChild().getNodeValue()); children.add((Element) child); } } return children.iterator(); } }