Here you can find the source of getAttributeValue(Element el, String attrName)
public static String getAttributeValue(Element el, String attrName)
//package com.java2s; //License from project: Apache License import javax.xml.namespace.QName; import org.w3c.dom.Element; public class Main { /** //ww w. java 2 s . c o m * Get the value from the given attribute * @return null if the attribute value is empty or the attribute is not present */ public static String getAttributeValue(Element el, String attrName) { return getAttributeValue(el, new QName(attrName)); } /** * Get the value from the given attribute * @return null if the attribute value is empty or the attribute is not present */ public static String getAttributeValue(Element el, QName attrName) { String attr = null; if ("".equals(attrName.getNamespaceURI())) attr = el.getAttribute(attrName.getLocalPart()); else attr = el.getAttributeNS(attrName.getNamespaceURI(), attrName.getLocalPart()); if ("".equals(attr)) attr = null; return attr; } }