Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.LinkedHashMap; import java.util.Map; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; public class Main { /** * get attribute map from the element * @param el - element * @return mapping of attributes */ public static Map<String, String> getAttributes(Element el) { Map<String, String> list = new LinkedHashMap<String, String>(); NamedNodeMap map = el.getAttributes(); for (int i = 0; i < map.getLength(); i++) { list.put(map.item(i).getNodeName(), map.item(i).getNodeValue()); } return list; } }