擅长:python、mysql、java
<p>已经提到lxml。您还可以查看<a href="http://codespeak.net/lxml/objectify.html" rel="noreferrer">lxml.objectify</a>以获得一些真正简单的操作。</p>
<pre><code>>>> from lxml import objectify
>>> tree = objectify.fromstring(your_xml)
>>> tree.weather.attrib["module_id"]
'0'
>>> tree.weather.forecast_information.city.attrib["data"]
'Mountain View, CA'
>>> tree.weather.forecast_information.postal_code.attrib["data"]
'94043'
</code></pre>