Here you can find the source of getChildElementsByTagName(Element elem, String name)
public static List<Element> getChildElementsByTagName(Element elem, String name)
//package com.java2s; //License from project: Open Source License 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> getChildElementsByTagName(Element elem, String name) { List<Element> result = new ArrayList<Element>(); NodeList nodeList = elem.getChildNodes(); for (int i = 0; i < nodeList.getLength(); i++) { Node child = nodeList.item(i); if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals(name)) { result.add((Element) child); }/*w ww. j av a2s . com*/ } return result; } }