Here you can find the source of getNamespaceDeclarationOrNull(String localName, Element element)
public static Node getNamespaceDeclarationOrNull(String localName, Element element)
//package com.java2s; //License from project: Open Source License import org.w3c.dom.*; public class Main { public static Node getNamespaceDeclarationOrNull(String localName, Element element) { NamedNodeMap map = element.getAttributes(); for (int i = 0; i < map.getLength(); i++) { Node node = map.item(i); String nsUri = node.getNamespaceURI(); if (nsUri == null) { continue; }// w w w . j ava 2s . co m if ("http://www.w3.org/2000/xmlns/".equals(nsUri) && localName.equals(node.getLocalName())) { return node; } } return null; } }