Java XML Node Namespace getNamespaces(Node node, Map list)

Here you can find the source of getNamespaces(Node node, Map list)

Description

get Namespaces

License

Apache License

Declaration

public static void getNamespaces(Node node, Map<String, String> list) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Map;

import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;

public class Main {
    public static void getNamespaces(Node node, Map<String, String> list) {
        NamedNodeMap atts = node.getAttributes();
        for (int i = 0; i < atts.getLength(); i++) {
            Node n = atts.item(i);
            if ("xmlns".equals(n.getNodeName())) {
                list.put(n.getNodeName(), n.getNodeValue());
            } else {
                if (n.getNodeName().startsWith("xmlns:")) {
                    list.put(n.getNodeName().substring(6), n.getNodeValue());
                }/*from  www .  j  a va2s .  c  o m*/
            }
        }
    }
}

Related

  1. getNamespace(Node node)
  2. getNamespace(Node node)
  3. getNamespace(String prefix, Node e)
  4. getNamespaceDeclarations(Node node)
  5. getNamespaceMappings(Node node)
  6. getNamespaceURI(@Nullable final Node aNode)
  7. getNamespaceURI(final org.w3c.dom.Node n, final String prefix)
  8. getNamespaceURI(Node node)
  9. getNamespaceUri(Node node)