Java XML Attribute Get getDoubleAttribute(Element element, String name)

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

Description

get Double Attribute

License

Apache License

Declaration

static public double getDoubleAttribute(Element element, String name) 

Method Source Code

//package com.java2s;
/**/*from w w w  . ja  v  a  2s  . com*/
 * Copyright 2014, Emory University
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import org.w3c.dom.Element;

public class Main {
    static public double getDoubleAttribute(Element element, String name) {
        String s = getTrimmedAttribute(element, name);
        return s.isEmpty() ? 0d : Double.parseDouble(s);
    }

    static public String getTrimmedAttribute(Element element, String name) {
        return element.getAttribute(name).trim();
    }
}

Related

  1. getClosestAncestorWithAttribute(Node node, String ancestorName, String attributeName)
  2. getCurrentLevelAttributeTextValue(Element ele, String attribute)
  3. getDirectAttribute(Node node, String name)
  4. getDivHeadAttr(Element annotU, String attrName)
  5. getDoubleArrayTagAttribute(XMLStreamReader xmler, String attribute, double[] defaultValue)
  6. getDoubleAttribute(Node n, String s)
  7. getDoubleAttribute(String name, Element el)
  8. getDoubleAttributeValue(Element element, String attribute)
  9. getDoubleAttributeValue(final Element element, final String attributeName)