public static String getAttributeValue(final Node elementNode, final String attrName, final String defValue)
    {
        final Node attrNode = elementNode.getAttributes().getNamedItemNS(null, attrName);

        if (attrNode == null)
        {
            return defValue;
        }

        return attrNode.getNodeValue();
    }
public static String getAttributeValue ( final Node elementNode , final String attrName , final String defValue ) { final Node attrNode = elementNode . getAttributes ( ) . getNamedItemNS ( null , attrName ) ; if ( attrNode == null ) { return defValue ; } return attrNode . getNodeValue ( ) ; }
Helper function that uses a default value when value not set.

@param elementNode that should have the attribute
@param attrName    that is to be looked up
@param defValue    String to return if not set
@return value of the attribute or defValue