Here you can find the source of getNodeAttribute(Node node, String name, String def)
public static String getNodeAttribute(Node node, String name, String def)
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; public class Main { public static String getNodeAttribute(Node node, String name) { return getNamedItemNodeValue(node.getAttributes(), name, null); }/*from w w w . j a va 2s .com*/ public static String getNodeAttribute(Node node, String name, String def) { return getNamedItemNodeValue(node.getAttributes(), name, def); } static String getNamedItemNodeValue(NamedNodeMap attributes, String name, String defvalue) { Node namenode = attributes.getNamedItem(name); if (namenode == null) { return defvalue; } if (namenode.getNodeValue() == null) { return defvalue; } return namenode.getNodeValue(); } }