Java tutorial
//package com.java2s; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; public class Main { public static Properties getElementAttributes(Element ele) { Properties ht = new Properties(); NamedNodeMap nnm = ele.getAttributes(); int len = nnm.getLength(); Node tmpn = null; for (int k = 0; k < len; k++) { tmpn = nnm.item(k); String tmps = tmpn.getNodeValue(); if (tmps == null) { tmps = ""; } ht.put(tmpn.getNodeName(), tmps); } return ht; } }