Java examples for XML:XML Attribute
get DOM Attr by attribute name
//package com.java2s; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; public class Main { public static String getAttr(Node node, String attrName) { NamedNodeMap namedNodeMap = node.getAttributes(); if (namedNodeMap != null) { Node attr = namedNodeMap.getNamedItem(attrName); if (attr != null) { return attr.getNodeValue(); }/* w ww . jav a 2s . co m*/ } return null; } }