2024-10-01 13:34:28 发布
网友
我尝试使用lxml在Python中解析XML文件,如下所示:
objectify.parse(xmlPath, parserWithSchema)
但XML文件可能在奇怪的地方包含注释:
这是一种在解析之前不加载或删除注释的方法吗?在
在解析器(documentation)上设置remove_comments=True:
remove_comments=True
from lxml import etree, objectify parser = etree.XMLParser(remove_comments=True) tree = objectify.parse(xmlPath, parser=parser)
或者,使用makeparser()方法:
makeparser()
希望有帮助。在
在解析器(documentation)上设置
remove_comments=True
:或者,使用
^{pr2}$makeparser()
方法:希望有帮助。在
相关问题 更多 >
编程相关推荐