Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.HashMap; import java.util.Map; import org.w3c.dom.Attr; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; public class Main { public static Map<String, String> getMapOfAttributes(Node elem) { Map<String, String> attrs = new HashMap<String, String>(); NamedNodeMap m = elem.getAttributes(); if (m != null) { for (int i = 0; i < m.getLength(); ++i) { Attr a = (Attr) m.item(i); attrs.put(a.getName(), a.getValue()); } } return attrs; } }