Here you can find the source of getNodeAttributeOrFail( Node node, String name, ExceptionType e)
public static <ExceptionType extends Exception> String getNodeAttributeOrFail( Node node, String name, ExceptionType e) throws ExceptionType
//package com.java2s; //License from project: Open Source License import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; public class Main { public static <ExceptionType extends Exception> String getNodeAttributeOrFail( Node node, String name, ExceptionType e) throws ExceptionType { NamedNodeMap attributes = node.getAttributes(); Node valueNode = attributes.getNamedItem(name); if (valueNode == null) throw e; return valueNode.getNodeValue(); }/* w w w .j a v a2 s.co m*/ }