Java XML Attribute Get getBooleanAttributeValue(Node node, String attribute)

Here you can find the source of getBooleanAttributeValue(Node node, String attribute)

Description

get Boolean Attribute Value

License

Open Source License

Declaration

public static Boolean getBooleanAttributeValue(Node node, String attribute) 

Method Source Code


//package com.java2s;
import org.w3c.dom.Node;

public class Main {
    public static Boolean getBooleanAttributeValue(Node node, String attribute) {
        String value = getAttributeValue(node, attribute);

        if (value == null)
            return null;

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

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

        return false;
    }//from   www  .ja  v  a  2  s. c  om

    public static String getAttributeValue(Node node, String attribute) {
        Node att = node.getAttributes().getNamedItem(attribute);

        if (att == null)
            return null;

        return att.getTextContent();
    }
}

Related

  1. getBooleanAttribute(Node targetElem, String keyName, boolean defaultValue)
  2. getBooleanAttributeByName(Node content, String attributeName, boolean defaultTrue)
  3. getBooleanAttributeOption(final Element configuration, final String option, boolean defaultValue)
  4. getBooleanAttributeOptional(Node node, String attributeName, Boolean valueIfEmpty)
  5. getBooleanAttributeRequired(Node node, String attributeName)
  6. getCascadeValue(final Element elem, final String attrName)
  7. getClosestAncestorWithAttribute(Node node, String ancestorName, String attributeName)
  8. getClosestAncestorWithAttribute(Node node, String ancestorName, String attributeName)
  9. getCurrentLevelAttributeTextValue(Element ele, String attribute)