code: def validate_xml_text(text):
      
      bad_chars = __INVALID_XML_CHARS & set(text)
      if bad_chars:
          for offset,c in enumerate(text):
              if c in bad_chars:
                  raise RuntimeError('invalid XML character: ' + repr(c) + ' at offset ' + str(offset))
docs: validates XML text