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

前端 未结 13 1045
日久生厌
日久生厌 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:35

    I have been in stuck with similar problem. Finally figured out the what was the root cause in my particular case. If you read the data from multiple XML files that lie in same folder you will parse also .DS_Store file. Before parsing add this condition

    for file in files:
        if file.endswith('.xml'):
           run_your_code...
    

    This trick helped me as well

提交回复
热议问题