Here you can find the source of getElementsByTagName(Element node, String xmlns, String nodeName)
public static List<Node> getElementsByTagName(Element node, String xmlns, String nodeName)
//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 { /**/*ww w . ja v a 2 s . c om*/ * Putting this in TestUtil and not XmlUtil since any production code could probably benefit by doing other work while iterating over NodeList * directly, as opposed to looping once to construct this list we return, then iterating over it again to do such work. */ public static List<Node> getElementsByTagName(Element node, String xmlns, String nodeName) { List<Node> nodes = new ArrayList<Node>(); NodeList nodeList = node.getElementsByTagNameNS(xmlns, nodeName); for (int i = 0; i < nodeList.getLength(); i++) { nodes.add(nodeList.item(i)); } return nodes; } }