Java tutorial
//package com.java2s; import org.w3c.dom.Node; public class Main { /** * * @param node * @param name * @return */ public static int getIntAttribute(Node node, String name) { String value = getStringAttribute(node, name); if (value != null && !value.isEmpty()) { return Integer.valueOf(value).intValue(); } else { return 0; } } /** * * @param node * @param name * @return */ public static String getStringAttribute(Node node, String name) { Node attribute = node.getAttributes().getNamedItem(name); if (attribute != null) { return attribute.getNodeValue(); } else { return null; } } }