Here you can find the source of getNodeAttributeOrDefault(Node node, String name, String defaultValue)
public static String getNodeAttributeOrDefault(Node node, String name, String defaultValue)
//package com.java2s; //License from project: Open Source License import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; public class Main { public static String getNodeAttributeOrDefault(Node node, String name, String defaultValue) { NamedNodeMap attributes = node.getAttributes(); Node valueNode = attributes.getNamedItem(name); String value = defaultValue; if (valueNode != null) value = valueNode.getNodeValue(); return value; }/*from w w w. j av a 2 s.c o m*/ }