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> getAttributes(Node p_node) throws Exception { NamedNodeMap l_nnm = null; Node l_n = null; String l_an = null; String l_av = null; HashMap<String, String> l_a = new HashMap<String, String>(); l_nnm = p_node.getAttributes(); if (l_nnm != null) { for (int l_i = 0; l_i < l_nnm.getLength(); l_i++) { l_n = l_nnm.item(l_i); l_an = l_n.getNodeName(); l_av = l_n.getNodeValue(); l_a.put(l_an, l_av); } } return l_a; } public static void getAttributes(Node p_node, HashMap<String, String> p_map) throws Exception { NamedNodeMap l_nnm = null; Node l_n = null; String l_an = null; String l_av = null; l_nnm = p_node.getAttributes(); if (l_nnm != null) { for (int l_i = 0; l_i < l_nnm.getLength(); l_i++) { l_n = l_nnm.item(l_i); l_an = l_n.getNodeName(); l_av = l_n.getNodeValue(); p_map.put(l_an, l_av); } } } }