试图从美国专利和贸易局读取大量数据。我尝试了几次xml files from here,得到了相同的结果:
import xml.etree.ElementTree as ET
import re
file = 'ipgb20210105.xml'
tree = ET.parse(file)
产生:“ParseError:文档元素后的垃圾:第862行,第0列”
已尝试recommendation to wrap with fake root node,但这也不起作用:
with open(file) as f:
xml = f.read()
tree = ET.fromstring(re.sub(r"(<\?xml[^>]+\?>)", r"\1<root>", xml) + "</root>")
产生:“ParseError:格式不正确(无效令牌):第2行第2列”
非常感谢任何帮助
目前没有回答
相关问题 更多 >
编程相关推荐