Here you can find the source of getChildElements(Element e, String tag)
public static List<Element> getChildElements(Element e, String tag)
//package com.java2s; 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> getChildElements(Element e, String tag) { NodeList children = e.getElementsByTagName(tag); if (children == null || children.getLength() == 0) return null; List<Element> result = new ArrayList<Element>(); for (int index = 0; index < children.getLength(); index++) { Node n = children.item(index); if (n.getNodeType() == Node.ELEMENT_NODE) { result.add((Element) n); }/*from w w w . j a va 2s. co m*/ } return result; } }