简体   繁体   English

无法解析 Python 中的 XML 文件

[英]Unable to Parse XML file in Python

I am trying to parse a large xml file (more than 50mb).我正在尝试解析一个大型 xml 文件(超过 50mb)。 Getting the following parsing error.得到以下解析错误。 File attached for reference.附上文件供参考。 File文件

import xml.etree.cElementTree as ET
tree = ET.parse('input_file.xml')

error
 File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/xml/etree/ElementTree.py", line 598, in parse
    self._root = parser._parse_whole(source)

  File "<string>", line unknown
ParseError: no element found: line 21, column 0

You XML is not well-formed, ElementTree cannot parse it.您的 XML 格式不正确,ElementTree 无法解析。 Please take look at your XML file and check whether it has a proper closing tag, maybe special characters and other stuff.请查看您的 XML 文件并检查它是否有正确的结束标签,可能是特殊字符和其他内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM