Here you can find the source of getElementAttr(Node element, String attrName)
public static String getElementAttr(Node element, String attrName)
//package com.java2s; import org.w3c.dom.Node; public class Main { public static String getElementAttr(Node element, String attrName) { if (element.getAttributes() != null) { for (int i = 0; i < element.getAttributes().getLength(); i++) { Node child = element.getAttributes().item(i); if (child.getNodeName().equals(attrName)) { return child.getNodeValue(); }// www. j a va2s. c o m } } return null; } }