Java tutorial
//package com.java2s; import org.w3c.dom.Node; public class Main { public static double getDouble(Node aNode, String attr) { return getDouble(aNode, attr, Double.NaN); } public static double getDouble(Node aNode, String attr, double defaultValue) { if (aNode.getAttributes().getNamedItem(attr) != null) { String attrString = aNode.getAttributes().getNamedItem(attr).getNodeValue(); double year = Double.parseDouble(attrString); return year; } else { return defaultValue; } } }