Here you can find the source of getStringAttributeRequired(Node node, String attributeName)
public static String getStringAttributeRequired(Node node, String attributeName) throws Exception
//package com.java2s; //License from project: Apache License import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; public class Main { public static String getStringAttributeRequired(Node node, String attributeName) throws Exception { NamedNodeMap attributes = node.getAttributes(); Node value = attributes.getNamedItem(attributeName); if (value == null) { throw new Exception("Missing attribute '" + attributeName + "' in node '" + node.getNodeName() + "'"); }/* w w w.ja va 2 s . co m*/ String text = value.getTextContent(); if (text == null) { throw new Exception("Missing text '" + attributeName + "' in node '" + node.getNodeName() + "'"); } return text; } }