code: def quoted_attribute_value(self, value):
          
          quote_with = '"'
          if '"' in value:
              if "'" in value:
                  # The string contains both single and double
                  # quotes.  Turn the double quotes into
                  # entities. We quote the double quotes rather than
                  # the single quotes because the entity name is
                  # "&quot;" whether this is HTML or XML.  If we
                  # quoted the single quotes, we'd have to decide
                  # between &apos; and &squot;.
                  replace_with = "&quot;"
                  value = value.replace('"', replace_with)
              else:
                  # There are double quotes but no single quotes.
                  # We can use single quotes to quote the attribute.
                  quote_with = "'"
          return quote_with + value + quote_with
docs: Make a value into a quoted XML attribute, possibly escaping it.
  
           Most strings will be quoted using double quotes.
  
            Bob's Bar -> "Bob's Bar"
  
           If a string contains double quotes, it will be quoted using
           single quotes.
  
            Welcome to "my bar" -> 'Welcome to "my bar"'
  
           If a string contains both single and double quotes, the
           double quotes will be escaped, and the string will be quoted
           using double quotes.
  
            Welcome to "Bob's Bar" -> "Welcome to &quot;Bob's bar&quot;