擅长:python、mysql、java
<p>阅读<a href="http://docs.python.org/2/library/xml.etree.elementtree.html" rel="nofollow">the docs</a>获取<code>etree</code>的列表(带示例),其中列出了遍历DOM和检索数据所能做的一切。如果您对<a href="http://en.wikipedia.org/wiki/XPath" rel="nofollow">xpath</a>不熟悉,您可能还想阅读它(即使这个模块<a href="http://docs.python.org/2/library/xml.etree.elementtree.html#xpath-support" rel="nofollow">does not fully support it</a>,您也可以使用它的子集轻松地检索一些元素)。对于您的具体示例,它将是:</p>
<pre><code>root.find('project[@name="proj1"]/design[@name="des2"]/param').text
</code></pre>