Here you can find the source of hasAttribute(Element element, String attribute)
public static boolean hasAttribute(Element element, String attribute)
//package com.java2s; import org.w3c.dom.Element; public class Main { /**//from w w w.j a v a 2s.com * @return true if the specified attribute is present and not empty or null in the element */ public static boolean hasAttribute(Element element, String attribute) { String s = element.getAttribute(attribute); if (s == null || "".equals(s)) { return false; } else { return true; } } }