我想使用pythonxmlementtreeapi解析以下XML文件。在
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<foos>
<foo_table>
<!-- bar -->
<fooelem>
<fname>BBBB</fname>
<group>SOMEGROUP</group>
<module>some module</module>
</fooelem>
<fooelem>
<fname>AAAA</fname>
<group>other group</group>
<module>other module</module>
</fooelem>
<!-- bar -->
</foo_table>
</foos>
在这个示例代码中,我尝试查找/foos/foo\u table/foolem/fname下的所有元素,但显然findall在运行此代码时找不到任何内容。在
^{pr2}$我没有使用elementtreeapi的经验,但是我使用了https://docs.python.org/2/library/xml.etree.elementtree.html#example下的示例。为什么在我的案子里没用?在
findall
不起作用,但可以:我的列表会有适当的长度。在
{root>使用的是元素。
请改用这个:
foo_table/fooelem/fname
foos
是你的root
,你需要从下面的findall
开始输出:
^{pr2}$相关问题 更多 >
编程相关推荐