Java tutorial
//package com.java2s; import org.w3c.dom.Node; public class Main { public static Long getLongVal(final Node node) { return getLongAttr(node, "val"); } public static Long getLongAttr(final Node node, String attrName) { final String val = getAttr(node, attrName); return val == null ? null : Long.parseLong(val, 10); } public static String getAttr(final Node node, String attrName) { return node == null ? null : node.getAttributes().getNamedItem(attrName).getTextContent(); } }