Here you can find the source of getAttribute(final Node node, final String attribname, final int def)
public static int getAttribute(final Node node, final String attribname, final int def)
//package com.java2s; //License from project: Apache License import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; public class Main { public static int getAttribute(final Node node, final String attribname, final int def) { final String attr = getAttributeValue(node, attribname); if (attr != null) { return Integer.parseInt(attr); } else {//from w w w .j a v a 2s .co m return def; } } public static String getAttributeValue(final Node node, final String attribname) { final NamedNodeMap attributes = node.getAttributes(); String att = null; if (attributes != null) { final Node attribute = attributes.getNamedItem(attribname); if (attribute != null) { att = attribute.getNodeValue(); } } return att; } }