Java tutorial
//package com.java2s; import java.util.List; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import com.google.common.collect.Lists; public class Main { public static Element[] getElementsByName(Element parent, String name) { List<Node> resList = Lists.newArrayList(); NodeList nl = getNodeList(parent); for (int i = 0; i < nl.getLength(); i++) { Node nd = nl.item(i); if (nd.getNodeName().equals(name)) { resList.add(nd); } } Element[] res = new Element[resList.size()]; for (int i = 0; i < resList.size(); i++) { res[0] = (Element) resList.get(i); } return res; } public static NodeList getNodeList(Element parent) { return parent.getChildNodes(); } }