code: def xmlchars(text):
      
      invalid = list(range(0x9))
      invalid.extend([0xb, 0xc])
      invalid.extend(range(0xe, 0x20))
      return re.sub('|'.join('\\x%0.2X' % i for i in invalid), '', text)
docs: Not all of UTF-8 is considered valid character data in XML ...
  
      Thus, this function can be used to remove illegal characters from ``text``.