Java XML Attribute Get getDoubleAttributeValue(final Element element, final String attributeName)

Here you can find the source of getDoubleAttributeValue(final Element element, final String attributeName)

Description

Get a double value from an attribute.

License

Open Source License

Parameter

Parameter Description
element the element to get the attribute from, may be null
attributeName the attribute name to get

Return

the value, null if element is null or the attribute value is null or empty

Declaration

public static Double getDoubleAttributeValue(final Element element, final String attributeName) 

Method Source Code

//package com.java2s;

import org.w3c.dom.Element;

public class Main {
    /**//from w  w w.  ja  v  a2s  . c  om
     * Get a double value from an attribute.
     * 
     * @param element the element to get the attribute from, may be null
     * @param attributeName the attribute name to get
     * @return the value, null if element is null or the attribute value is null
     *         or empty
     */
    public static Double getDoubleAttributeValue(final Element element, final String attributeName) {
        if (null == element) {
            return null;
        }
        final String str = element.getAttribute(attributeName);
        if (str.isEmpty()) {
            return null;
        } else {
            return Double.valueOf(str);
        }
    }
}

Related

  1. getDoubleArrayTagAttribute(XMLStreamReader xmler, String attribute, double[] defaultValue)
  2. getDoubleAttribute(Element element, String name)
  3. getDoubleAttribute(Node n, String s)
  4. getDoubleAttribute(String name, Element el)
  5. getDoubleAttributeValue(Element element, String attribute)