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