Java XML Attribute Get getBoolAttribute(Node node, String name)

Here you can find the source of getBoolAttribute(Node node, String name)

Description

get Bool Attribute

License

Open Source License

Declaration

public static boolean getBoolAttribute(Node node, String name) 

Method Source Code

//package com.java2s;

import org.w3c.dom.Node;

public class Main {
    public static boolean getBoolAttribute(Node node, String name) {
        return Boolean.parseBoolean(getAttribute(node, name));
    }//from w  w w.  j  a  v a2s.  c o m

    public static boolean getBoolAttribute(Node node, String name,
            boolean defVal) {
        String att = getAttribute(node, name);
        if (att == null)
            return defVal;
        return Boolean.parseBoolean(att);
    }

    /**
     * Returns an attribute of the specified tag with the name provided.
     *
     * @param node
     * @param name
     * @return The attribute if its defined, or null.
     */
    public static String getAttribute(Node node, String name, String defVal) {
        Node att = node.getAttributes().getNamedItem(name);
        return att == null ? defVal : att.getNodeValue();
    }

    public static String getAttribute(Node node, String name) {
        return getAttribute(node, name, null);
    }
}

Related

  1. getAttrValuesByName(Element ele, String attributeName)
  2. getBeanclassAttribute(Node node)
  3. getBool(Element el, String attrName, boolean defaultValue)
  4. getBoolAttribute(NamedNodeMap namedNodeMap, String name)
  5. getBoolAttribute(Node node, String attr)
  6. getBoolAttribute(Node node, String name, boolean defVal)
  7. getBoolean(Element element, String attribute, boolean defaultValue)
  8. getBooleanAttr(Element element, String name)
  9. getBooleanAttrib(Element element, String attribName, String namespaceURI)