Java tutorial
//package com.java2s; //License from project: Apache License import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import java.util.ArrayList; import java.util.List; public class Main { public static List<Element> getChildElements(Element elem, String name) { NodeList nodes = elem.getElementsByTagName(name); List<Element> elements = new ArrayList<Element>(nodes.getLength()); for (int i = 0; i < nodes.getLength(); i++) { Node node = nodes.item(i); if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals(name)) { elements.add((Element) node); } } return elements; } }