Here you can find the source of getChildElementsByTagName(Element parentElement, String childTag)
public static List<Element> getChildElementsByTagName(Element parentElement, String childTag)
//package com.java2s; /*/* w w w. ja v a 2 s.c o m*/ * JFox - The most lightweight Java EE Application Server! * more details please visit http://www.huihoo.org/jfox or http://www.jfox.org.cn. * * JFox is licenced and re-distributable under GNU 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> getChildElementsByTagName(Element parentElement, String childTag) { NodeList nodelist = parentElement.getChildNodes(); List<Element> nodes = new ArrayList<Element>(); for (int i = 0; i < nodelist.getLength(); i++) { Node temp = nodelist.item(i); if (temp.getNodeType() == Node.ELEMENT_NODE && temp.getNodeName().equals(childTag)) { nodes.add((Element) temp); } } return nodes; } }