擅长:python、mysql、java
<p>因此,现在我的框中有ElementTree 1.2.6,并对您发布的XML块运行以下代码:</p>
<pre><code>import elementtree.ElementTree as ET
tree = ET.parse("test.xml")
doc = tree.getroot()
thingy = doc.find('timeSeries')
print thingy.attrib
</code></pre>
<p>得到了以下信息:</p>
<pre><code>{'name': 'NWIS Time Series Instantaneous Values'}
</code></pre>
<p>它似乎在不需要使用数字索引的情况下找到了timeSeries元素。</p>
<p>现在有用的是知道当你说“它不起作用”时你的意思,因为它对我同样的输入起作用,所以不太可能以某种明显的方式破坏ElementTree。使用任何错误消息、回溯或您可以提供的任何帮助来更新您的问题。</p>