Here you can find the source of getElementsByTagName(Element element, String tagName)
public static List<Element> getElementsByTagName(Element element, String tagName)
//package com.java2s; /*/*from w w w . j av a 2 s . com*/ * 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> getElementsByTagName(Element element, String tagName) { ArrayList<Element> children = new ArrayList<Element>(); if (element != null && tagName != null) { NodeList nodes = element.getElementsByTagName(tagName); for (int i = 0; i < nodes.getLength(); i++) { Node child = nodes.item(i); children.add((Element) child); } } return children; } }