Here you can find the source of getChildElementsByName(Element parent, String elemName)
public static List<Element> getChildElementsByName(Element parent, String elemName)
//package com.java2s; //License from project: LGPL 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> getChildElementsByName(Element parent, String elemName) { List<Element> result = new ArrayList<Element>(); NodeList nl = parent.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { if (nl.item(i).getNodeType() == Node.ELEMENT_NODE) { Element elem = (Element) nl.item(i); if (elem.getNodeName().equals(elemName)) result.add(elem);//from w w w.ja v a 2s .c o m } } return result; } }