Here you can find the source of getChildElementsByTagName(Element element, String name)
public static List<Element> getChildElementsByTagName(Element element, String name)
//package com.java2s; //License from project: Apache 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 element, String name) { List<Element> result = new ArrayList<Element>(); NodeList childNodes = element.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node node = childNodes.item(i); if (node instanceof Element) { String nodeName = node.getNodeName(); if (nodeName != null) { if (nodeName.equals(name)) { result.add((Element) childNodes.item(i)); }/* w w w .java 2 s. c o m*/ } } } if (result.size() == 0) { result = null; } return result; } }