Here you can find the source of getAttribute(Element aElement, String aAttr, String aDefault)
Parameter | Description |
---|---|
aElement | The owning <code>Element</code>. |
aAttr | The name of the attribute. |
aDefault | The default value if the attribute value is empty. |
public static String getAttribute(Element aElement, String aAttr, String aDefault)
//package com.java2s; import org.w3c.dom.Element; public class Main { /**/* w ww. j a va 2 s . c om*/ * Returns the value of the specified attribute from the given Element. * * @param aElement The owning <code>Element</code>. * @param aAttributeName The name of the attribute. * @return String */ public static String getAttribute(Element aElement, String aAttributeName) { return aElement.getAttribute(aAttributeName); } /** * Retrieves the given attribute from the given Element. If the attribute had an empty String * value then the default argument is returned. * * @param aElement The owning <code>Element</code>. * @param aAttr The name of the attribute. * @param aDefault The default value if the attribute value is empty. */ public static String getAttribute(Element aElement, String aAttr, String aDefault) { String str = getAttribute(aElement, aAttr); return str.equals("") ? aDefault : str; //$NON-NLS-1$ } }