Java XML Attribute Get getAttribAsBoolean(Element e, String name, Boolean dft)

Here you can find the source of getAttribAsBoolean(Element e, String name, Boolean dft)

Description

get Attrib As Boolean

License

Open Source License

Declaration

public static Boolean getAttribAsBoolean(Element e, String name, Boolean dft) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import org.w3c.dom.Element;

public class Main {
    public static Boolean getAttribAsBoolean(Element e, String name) {
        return getAttribAsBoolean(e, name, false);
    }/*from   w  w w.j a v a2s. c om*/

    public static Boolean getAttribAsBoolean(Element e, String name, Boolean dft) {
        if (getAttribute(e, name) == null)
            return dft;
        else
            return Boolean.parseBoolean(getAttribute(e, name));
    }

    public static String getAttribute(Element e, String name) {
        if (e.getAttribute(name) == null)
            return "";
        return e.getAttribute(name);
    }
}

Related

  1. getAttr(Node node, String name)
  2. getAttr(Node node, String name, String defaultValue)
  3. getAttrBool(Node n, String name)
  4. getAttrDate(Element elem, String localName)
  5. getAttrib(NamedNodeMap attribs, String name)
  6. getAttribAsFloat(Element e, String name, Float dft)
  7. getAttribBoolean(Element ele, String name)
  8. getAttribByName(Element node, String name)
  9. getAttribFloat(Element ele, String name)