Java tutorial
//package com.java2s; import org.w3c.dom.*; public class Main { /** * Getter for the attribute value of an attribute of the given name * for the specified node. The attribute value is returned as a string. * @param node Node. * @param name Name of the attribute. * @return Returns the attribute value as string or null if the attribute * does not exist. */ static public String getAttrValString(Node node, String name) { NamedNodeMap attr = node.getAttributes(); if (attr != null) { node = attr.getNamedItem(name); if (node != null) return (node.getNodeValue()); } return (null); } }