Python 为什么我能';不能使用Xpath`.//node name`访问节点?

Python 为什么我能';不能使用Xpath`.//node name`访问节点?,python,xml,xpath,elementtree,Python,Xml,Xpath,Elementtree,xml文件如下所示: <?xml version="1.0" ?> <?xml-stylesheet type="text/xsl" href="Cistrome.xsl"?> <motifs> <motif id="hPDI060"> .......... </motif> </motifs> tree = ElementTree.parse(sys.argv[1]) for node in

xml文件如下所示:

<?xml version="1.0" ?>
<?xml-stylesheet type="text/xsl" href="Cistrome.xsl"?>
<motifs>
  <motif id="hPDI060">
  ..........
  </motif>
</motifs>
    tree = ElementTree.parse(sys.argv[1])
    for node in tree.findall('.//motifs'):
        print("found")
但是,在我运行代码之后,
found
字符串不会显示,换句话说,
//motif
找不到正确的标记

有人对此有想法吗?谢谢

将查找当前标记的所有子元素,而当前标记为“motif”。因此,没有任何发现

您可以通过以下方式检查当前标记是什么

> tree.tag
> 'motifs'
确保找到您想要的,
motif
motif
树。findall('*')
将在根元素
motif
下找到所有
motif