Java tutorial
//package com.java2s; import org.w3c.dom.*; public class Main { public static long getAttrLong(Node node, String attrName) { String s = getAttribute(node, attrName); if (s != null) { return Long.parseLong(s); } return -1L; } public static String getAttribute(Node node, String attrName) { NamedNodeMap attr = node.getAttributes(); if (attr != null) { Node nodeAttr = attr.getNamedItem(attrName); if (nodeAttr != null) { return nodeAttr.getNodeValue(); } } return null; } }