def _xml_escape_attr(attr, skip_single_quote=True):
 escaped = attr.replace('&', '&amp;').replace('"', '&quot;').replace('<', '&lt;').replace('>', '&gt;')
 if (not skip_single_quote):
  escaped = escaped.replace("'", '&#39;')
 return escaped

def _xml_escape_attr ( attr , skip_single_quote = True ) : escaped = attr . replace ( '&' , '&amp;' ) . replace ( '"' , '&quot;' ) . replace ( '<' , '&lt;' ) . replace ( '>' , '&gt;' ) if ( not skip_single_quote ) : escaped = escaped . replace ( "'" , '&#39;' ) return escaped
escape the given string for use in an html/xml tag attribute .