Here you can find the source of getElement(Document owner, String elementName, String nsURI)
Parameter | Description |
---|---|
owner | Document object to search. |
elementName | local name to search for. |
nsURI | namespaceURI to used (may be null). |
null
if none is found.
public static Element getElement(Document owner, String elementName, String nsURI)
//package com.java2s; //License from project: Open Source License import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; public class Main { /**//from w w w. j a va 2s .c om * Returns the Element object corresponding to the given element name. * * @param owner Document object to search. * @param elementName local name to search for. * @param nsURI namespaceURI to used (may be null). * @return the Element object corresponding to the given element name or * <code>null</code> if none is found. */ public static Element getElement(Document owner, String elementName, String nsURI) { NodeList nodes = nsURI != null ? owner.getElementsByTagNameNS(nsURI, elementName) : owner.getElementsByTagName(elementName); if (nodes != null && nodes.getLength() > 0) { return ((Element) nodes.item(0)); } return (null); } }