Here you can find the source of getAttr(NamedNodeMap attrs, String name)
public static String getAttr(NamedNodeMap attrs, String name)
//package com.java2s; //License from project: Apache License import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; public class Main { public static String getAttr(NamedNodeMap attrs, String name) { return getAttr(attrs, name, null); }/* ww w.j a va 2 s. com*/ public static String getAttr(Node nd, String name) { return getAttr(nd.getAttributes(), name); } public static String getAttr(NamedNodeMap attrs, String name, String missing_err) { Node attr = attrs == null ? null : attrs.getNamedItem(name); if (attr == null) { if (missing_err == null) return null; throw new RuntimeException(missing_err + ": missing mandatory attribute '" + name + "'"); } String val = attr.getNodeValue(); return val; } public static String getAttr(Node node, String name, String missing_err) { return getAttr(node.getAttributes(), name, missing_err); } }