Java XML Attribute Get getAttributeBoolean(final Element element, final String name)

Here you can find the source of getAttributeBoolean(final Element element, final String name)

Description

Locate attribute tagged 'name', return its boolean value.

License

Open Source License

Parameter

Parameter Description
element Element where to start looking.
name Name of the attribute.

Return

Returns true if attribute was "true". Defaults to false.

Declaration

public static final boolean getAttributeBoolean(final Element element, final String name) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2010 Oak Ridge National Laboratory.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 ******************************************************************************/

import org.w3c.dom.Element;

public class Main {
    /** Locate attribute tagged 'name', return its boolean value.
     *//w  ww.jav a2  s  . com
     *  @param element Element where to start looking.
     *  @param name Name of the attribute.
     *
     *  @return Returns true if attribute was "true". Defaults to false.
     */
    public static final boolean getAttributeBoolean(final Element element, final String name) {
        String s = element.getAttribute(name);
        return s.equalsIgnoreCase("true");
    }
}

Related

  1. getAttributeAsString(NamedNodeMap attributes, String name)
  2. getAttributeAsString(XMLStreamReader reader, String name)
  3. getAttributeAsURIString(XMLStreamReader reader, String name)
  4. getAttributeBoolean(Element aElement, String aAttributeName)
  5. getAttributeBoolean(Element el, String label)
  6. getAttributeBoolean(final Node node, final String name, final Boolean defaultValue)
  7. getAttributeBoolean(Node node, String attributeName)
  8. getAttributeBoolean(Node node, String name)
  9. getAttributeBooleanByName(NamedNodeMap nnm, String name)