Android examples for XML:XML Attribute
get Attributes from Node and return a Map
//package com.java2s; import java.util.HashMap; import java.util.Map; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; public class Main { public static Map getAttributes(Node node) { Map<String, String> attrMap = new HashMap<String, String>(); String attrValue = null;/* www .j a v a2 s .c o m*/ String attrName = null; NamedNodeMap attrs = node.getAttributes(); for (int j = 0; j < attrs.getLength(); j++) { Node attr = attrs.item(j); attrName = attr.getNodeName(); attrValue = attr.getNodeValue(); attrMap.put(attrName, attrValue); } return attrMap; } }