Here you can find the source of getAttribute(Node attrNode)
public static String getAttribute(Node attrNode)
//package com.java2s; import org.w3c.dom.Node; public class Main { public static String getAttribute(Node attrNode) { StringBuffer value = new StringBuffer(); if (attrNode != null && attrNode.getChildNodes().getLength() > 0) { int childCount = attrNode.getChildNodes().getLength(); for (int i = 0; i < childCount; i++) { value.append(attrNode.getChildNodes().item(i).getNodeValue()); }/*ww w . jav a 2s .c om*/ } return value.toString().trim(); } public static String getAttribute(Node node, String name) { if (!node.hasAttributes()) { return null; } StringBuffer value = new StringBuffer(); Node attrNode = node.getAttributes().getNamedItem(name); if (attrNode != null && attrNode.getChildNodes().getLength() > 0) { int childCount = attrNode.getChildNodes().getLength(); for (int i = 0; i < childCount; i++) { value.append(attrNode.getChildNodes().item(i).getNodeValue()); } } return value.toString().trim(); } }