我尝试使用lxml在Python中解析XML文件,像这样:
objectify.parse(xmlPath, parserWithSchema)
但是XML文件可能会在奇怪的地方包含注释:
<root>
<text>Sam<!--comment-->ple text</text>
<!--comment-->
<float>1.2<!--comment-->3456</float>
</root>
这是一种在解析之前不加载或删除注释的方法吗?
parser = objectify.makeparser(remove_comments=True)
,如此处所示https://dev59.com/WFjUa4cB1Zd3GeqPUsta#7513498 - RedX