Here you can find the source of getElementByTagNameNS(Node node, String namespaceURI, String localName)
static public Element getElementByTagNameNS(Node node, String namespaceURI, String localName)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.List; import org.w3c.dom.Document; import org.w3c.dom.NodeList; import org.w3c.dom.Node; import org.w3c.dom.Element; public class Main { static public Element getElementByTagNameNS(Node node, String namespaceURI, String localName) { NodeList nl;//from w w w .j a va 2s. c o m if (node.getNodeType() == Node.DOCUMENT_NODE) { nl = ((Document) node).getElementsByTagNameNS(namespaceURI, localName); } else if (node.getNodeType() == Node.ELEMENT_NODE) { nl = ((Element) node).getElementsByTagNameNS(namespaceURI, localName); } else { return null; } if (nl.getLength() > 0) { return (Element) nl.item(0); } else { return null; } } static public List<Element> getElementsByTagNameNS(Node node, String namespaceURI, String localName) { ArrayList<Element> list = new ArrayList<Element>(); NodeList nl; if (node.getNodeType() == Node.DOCUMENT_NODE) { nl = ((Document) node).getElementsByTagNameNS(namespaceURI, localName); } else if (node.getNodeType() == Node.ELEMENT_NODE) { nl = ((Element) node).getElementsByTagNameNS(namespaceURI, localName); } else { return null; } for (int i = 0; i < nl.getLength(); i++) { list.add((Element) nl.item(i)); } return list; } }