Java tutorial
//package com.java2s; /* * Copyright (c) 2000-2002 INSciTE. All rights reserved * INSciTE is on the web at: http://www.hightechkids.org * This code is released under GPL; see LICENSE.txt for details. */ import org.w3c.dom.Element; public class Main { /** * 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); } } }