Java tutorial
//package com.java2s; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; public class Main { public static String getAttributeValue(Node elementNode, String attributeName) { if (elementNode == null) { return null; } NamedNodeMap attributes = elementNode.getAttributes(); if (attributes == null) { return null; } Node attribute = attributes.getNamedItem(attributeName); if (attribute == null) { return null; } return attribute.getNodeValue(); } }