Here you can find the source of getAttribute(final Node node, final String attributeName)
public static String getAttribute(final Node node, final String attributeName)
//package com.java2s; //License from project: LGPL import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; public class Main { public static String getAttribute(final Node node, final String attributeName) { final NamedNodeMap tmpMap = node.getAttributes(); if (tmpMap == null) { return null; }/*from w w w .j a v a 2 s.c o m*/ final Node tmpNode = tmpMap.getNamedItem(attributeName); if (tmpNode == null) { return null; } return tmpNode.getNodeValue(); } public static String[] getAttributes(final Node node, final String[] attributeNames) { final String[] valueList = new String[attributeNames.length]; final NamedNodeMap attMap = node.getAttributes(); Node tmpNode = null; for (int i = 0; i < attributeNames.length; i++) { try { tmpNode = attMap.getNamedItem(attributeNames[i]); valueList[i] = tmpNode.getNodeValue(); } catch (Exception e) { valueList[i] = ""; } } // next attribute return valueList; } }