Here you can find the source of GetElement(Element root, String namespaceUri, String name, boolean throwIfNotFound)
public static Element GetElement(Element root, String namespaceUri, String name, boolean throwIfNotFound) throws Exception
//package com.java2s; import org.w3c.dom.*; public class Main { public static Element GetElement(Element root, String namespaceUri, String name, boolean throwIfNotFound) throws Exception { NodeList nodes = root.getElementsByTagNameNS(namespaceUri, name); if (nodes.getLength() > 0) return (Element) nodes.item(0); else {//from w w w .j a va2 s . c o m if (throwIfNotFound) throw new Exception( String.format( "A node with name '%s' in namespace '%s' was not found.", name, namespaceUri)); else return null; } } }