code: def remove_invalid_xml_chars(val):
      
      val = make_utf8(val)
      val = re.sub(u'[^\u0020-\uD7FF\u0009\u000A\u000D\uE000-\uFFFD\U00010000-\U0010FFFF]+', '?', val)
      return val
docs: Remove characters which aren't allowed in XML.
      :param val:
      :return: