Here you can find the source of getAttribute(Element e, String attrName, String def)
public static String getAttribute(Element e, String attrName, String def)
//package com.java2s; // modify it under the terms of the GNU General Public License import org.w3c.dom.Element; public class Main { public static String getAttribute(Element e, String attrName, String def) { String result = e.getAttribute(attrName); if (!hasValue(result)) result = def;// ww w . j a va 2s .c om return result; } public static boolean hasValue(String val) { return (val != null && val.length() > 0); } }