Java tutorial
//package com.java2s; import org.w3c.dom.Attr; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; public class Main { /** * @param node node * @param name attribute name * @return the attribute with the given name or <code>null</code> * if none found */ public static Attr findAttribute(Node node, String name) { NamedNodeMap attrs = node.getAttributes(); if (attrs == null) { return null; } return (Attr) attrs.getNamedItem(name); } }