Java XML Element Namespace getAllNamespaceDeclarations(Element element)

Here you can find the source of getAllNamespaceDeclarations(Element element)

Description

get All Namespace Declarations

License

Open Source License

Declaration

public static List<QName> getAllNamespaceDeclarations(Element element) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import org.w3c.dom.*;
import javax.xml.namespace.QName;

import java.util.ArrayList;
import java.util.List;

public class Main {
    public static List<QName> getAllNamespaceDeclarations(Element element) {
        List<QName> nodes = new ArrayList<>();
        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  av  a  2  s .  co  m*/
            if ("http://www.w3.org/2000/xmlns/".equals(nsUri)) {
                nodes.add(new QName(node.getTextContent(), node.getLocalName(), ""));
            }
        }
        return nodes;
    }
}

Related

  1. byteArrayToElement(byte[] b, boolean namespaceAware)
  2. createElement(final String namespace, final String localPart, final String value)
  3. createElement(String namespaceURI, String name)
  4. createElement(String namespaceURI, String name)
  5. createNamespace(Element el, String ns)
  6. getElementListNS(String namespace, Element element, String name)
  7. getElementNS(String namespace, Element element, String name)
  8. getNamespace(Element element)
  9. getNamespaceDeclarationOrNull(String localName, Element element)