Here you can find the source of getNamespaces(Node node, Map
public static void getNamespaces(Node node, Map<String, String> list)
//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*/ } } } }