Here you can find the source of getAllNamespaceDeclarations(Element element)
public static List<QName> getAllNamespaceDeclarations(Element element)
//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; } }