Code example for Attr

Methods: getValue

0
        Attr att = elem.getAttributeNode(attName);
 
        String value = null;
 
        if (att != null) {
            value = att.getValue();
        } 
 
        if (mandatory) {
            if (att == null) {
                throw new Exception("element " + elem.getNodeName()
                    + " does not contains an attribute named " + attName);
            } else if ("".equals(value)) {
                throw new Exception("attribute " + attName + "in element " + elem.getNodeName()
                    + " is empty"); 
            } 
        } 
 
        return value;
    }