Here you can find the source of getAttributes(Node node)
static public Map<QName, String> getAttributes(Node node)
//package com.java2s; //License from project: Open Source License import java.util.HashMap; import java.util.Map; import javax.xml.namespace.QName; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.Attr; public class Main { static public Map<QName, String> getAttributes(Node node) { Map<QName, String> atts = new HashMap<QName, String>(); NamedNodeMap nnm = node.getAttributes(); if (nnm != null) { for (int i = 0; i < nnm.getLength(); i++) { Attr att = (Attr) nnm.item(i); String uri = att.getBaseURI(); String localname = att.getLocalName(); String prefix = att.getPrefix(); QName name;/*from w ww .j a v a 2 s .c o m*/ if (uri == null) { name = new QName(localname); } else if (prefix == null) { name = new QName(uri, localname); } else { name = new QName(uri, localname, prefix); } if (prefix == null || !(prefix.equals("xmlns") || prefix.equals("xml"))) { atts.put(name, att.getValue()); } } } return atts; } }