Java tutorial
//package com.java2s; //License from project: Apache License import org.w3c.dom.Attr; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; public class Main { public static String getAttrvalue(Node item, String name, boolean ignoreNs) { NamedNodeMap attributes = item.getAttributes(); int numAttrs = attributes.getLength(); for (int i = 0; i < numAttrs; i++) { Attr attr = (Attr) attributes.item(i); String attrName = attr.getNodeName(); String NSName = attr.getNamespaceURI(); if (ignoreNs) { if ((attrName.indexOf(":" + name) != -1) || (name.equals(attrName))) return attr.getNodeValue(); } else { if (name.equals(attrName)) { return attr.getNodeValue(); } } } return null; } }