Java tutorial
//package com.java2s; import java.util.HashMap; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; public class Main { public static HashMap<String, String> getNodeAttributesMap(Node node) { HashMap<String, String> map = new HashMap<String, String>(); NamedNodeMap namedNodeMap = node.getAttributes(); for (int i = 0; i < namedNodeMap.getLength(); i++) { Node attribute = namedNodeMap.item(i); map.put(attribute.getNodeName(), attribute.getNodeValue()); } return map; } }