Java XML Element Namespace getNamespaceDeclarationOrNull(String localName, Element element)

Here you can find the source of getNamespaceDeclarationOrNull(String localName, Element element)

Description

get Namespace Declaration Or Null

License

Open Source License

Declaration

public static Node getNamespaceDeclarationOrNull(String localName, Element element) 

Method Source Code


//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;
    }
}

Related

  1. createNamespace(Element el, String ns)
  2. getAllNamespaceDeclarations(Element element)
  3. getElementListNS(String namespace, Element element, String name)
  4. getElementNS(String namespace, Element element, String name)
  5. getNamespace(Element element)
  6. getNamespaceForPrefix(String prefix, Element element)
  7. getNamespaceURI(Element element, String prefix)
  8. getNamespaceUriDeclaration(Element ele)
  9. getRequiredNamespaceDeclaration(String localName, Element element)