Here you can find the source of getAttributesAsMap(Element e)
public static Map<String, String> getAttributesAsMap(Element e)
//package com.java2s; // modify it under the terms of the GNU General Public License import java.util.HashMap; import java.util.Map; import org.w3c.dom.Attr; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; public class Main { /** Return the attributes from the specified element as a Map */ public static Map<String, String> getAttributesAsMap(Element e) { Map<String, String> result = new HashMap<String, String>(); NamedNodeMap attrs = e.getAttributes(); if (attrs != null) { int len = attrs.getLength(); for (int i = 0; i < len; i++) { Node n = attrs.item(i); if (n instanceof Attr) { Attr a = (Attr) n; result.put(a.getName(), a.getValue()); }/*from w w w .j a v a 2 s .c o m*/ } } return result; } }