code: def wash_for_xml(text, xml_version='1.0'):
      
      if xml_version == '1.0':
          return RE_ALLOWED_XML_1_0_CHARS.sub(
              '', unicode(text, 'utf-8')).encode('utf-8')
      else:
          return RE_ALLOWED_XML_1_1_CHARS.sub(
              '', unicode(text, 'utf-8')).encode('utf-8')
docs: Remove any character which isn't a allowed characters for XML.
  
      The allowed characters depends on the version
      of XML.
  
          - XML 1.0:
              <http://www.w3.org/TR/REC-xml/#charsets>
          - XML 1.1:
              <http://www.w3.org/TR/xml11/#charsets>
  
      :param text: input string to wash.
      :param xml_version: version of the XML for which we wash the
          input. Value for this parameter can be '1.0' or '1.1'