Java XML Attribute Get getAttrBool(Node n, String name)

Here you can find the source of getAttrBool(Node n, String name)

Description

get Attr Bool

License

LGPL

Declaration

public static boolean getAttrBool(Node n, String name) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import org.w3c.dom.*;

public class Main {
    public static boolean getAttrBool(Node n, String name) {
        if (n == null)
            return false; /* default value */

        Node nn = n.getAttributes().getNamedItem(name);
        if (nn == null)
            return false; /* default value */

        String value = nn.getNodeValue();

        if (value == null)
            return false; /* default value */

        if ("true".equals(value.toLowerCase()))
            return true;

        if ("1".equals(value.toLowerCase()))
            return true;

        return false;
    }//from  w w  w  .  j  av  a  2  s. co m
}

Related

  1. getAttr(NamedNodeMap attrs, String name, String missing_err)
  2. getAttr(Node n, String name)
  3. getAttr(Node node, String attr)
  4. getAttr(Node node, String name)
  5. getAttr(Node node, String name, String defaultValue)
  6. getAttrDate(Element elem, String localName)
  7. getAttrib(NamedNodeMap attribs, String name)
  8. getAttribAsBoolean(Element e, String name, Boolean dft)
  9. getAttribAsFloat(Element e, String name, Float dft)