ParseError: not well-formed (invalid token) using cElementTree

前端 未结 13 1036
日久生厌
日久生厌 2020-12-16 11:10

I receive xml strings from an external source that can contains unsanitized user contributed content.

The following xml string gave a ParseError in cElementTre

相关标签:
13条回答
  • 2020-12-16 11:49

    This code snippet worked for me. I have an issue with the parsing batch of XML files. I had to encode them to 'iso-8859-5'

    import xml.etree.ElementTree as ET
    
    tree = ET.parse(filename, parser = ET.XMLParser(encoding = 'iso-8859-5'))
    
    0 讨论(0)
提交回复
热议问题