extract_attribute function

Extract and optionally format a specific attribute