我试图解析一个只有几个attrib值的xml是整数。在这种情况下,python ElementTree类会引发ParseError
在xml.etree.ElementTree.ParseError:格式不正确(无效标记):第120行,列 umn 32号
这是我的xml
<Rectangle
leftTopX = 0
leftTopY = 0
rightBottomX = 20
rightBottomY = 40
/>
关于如何避免这个ParseError有什么建议吗?在
以下面的方式修改attrib值可以解决我的问题。但是我有多个xml文件要解析。更改属性值将花费更多时间。在
^{pr2}$
您可以切换到BeautifulSoup解析器,这在形式良好方面更为宽容。示例:
印刷品:
^{pr2}$您也可以将其与
^{3}$lxml
解析器一起使用(您需要安装lxml
):希望有帮助。在
相关问题 更多 >
编程相关推荐