擅长:python、mysql、java
<p>最简单的方法是使用<a href="https://pythonhosted.org/pyquery/" rel="nofollow">PyQuery</a>(如果您了解jQuery选择器):</p>
<pre><code>from pyquery import PyQuery
query = PyQuery(xml);
host = query("[Name='host'] value").text()
test_id = query("[Name='test-id'] value").text()
</code></pre>
<p>由于您有多个Name='host'的元素,因此应该迭代实体:</p>
<pre><code>from pyquery import PyQuery
def process_Entity(entity):
pass #do something
query = PyQuery(xml);
query("Entity").each(process_Entity)
</code></pre>