Java XML Attribute Get getAttribute(Element e, String attrName, String def)

Here you can find the source of getAttribute(Element e, String attrName, String def)

Description

get Attribute

License

Open Source License

Declaration

public static String getAttribute(Element e, String attrName, String def) 

Method Source Code

//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);
    }
}

Related

  1. getAttribString(Element ele, String name)
  2. getAttribURL(Element ele, String name, URL docRoot)
  3. getAttribute(Element aElement, String aAttr, String aDefault)
  4. getAttribute(Element e, String attName)
  5. getAttribute(Element e, String attribute)
  6. getAttribute(Element e, String name)
  7. getAttribute(Element e, String name)
  8. getAttribute(Element e, String name)
  9. getAttribute(Element e, String name)