Java tutorial
//package com.java2s; import org.w3c.dom.Node; public class Main { /** * Get the attribute with given name's value * * @param node * the node which attribute's value is returned * @param name * name of the attribute * @return the value af the attribute */ public static String getAttributeByName(Node node, String name) { if (node == null) { return null; } Node attribute = node.getAttributes().getNamedItem(name); if (attribute == null) { return null; } else { return attribute.getNodeValue().trim(); } } }