我一直在尝试提取在 XML 文件中看到的某些信息,但无法弄清楚如何从使用 FeedParser 提供的字典中提取它。这是原始 XML:
<SearchResults:searchresults xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SearchResults="http://www.zillow.com/static/xsd/SearchResults.xsd"
xsi:schemaLocation="http://www.zillow.com/static/xsd/SearchResults.xsd http://www.zillowstatic.com/vstatic/15706ff87bd1719552647e4e6eb2b722/static/xsd/SearchResults.xsd">
<request>
<address>411 Aldrich Ave</address>
<citystatezip>30079</citystatezip>
</request>
<message>
<text>Request successfully processed</text>
<code>0</code>
</message>
<response>
<results>
<result>
<zpid>2115831629</zpid>
<links>
<homedetails>
http://www.zillow.com/homedetails/411-Aldrich-Ave-Scottdale-GA-30079/2115831629_zpid/</homedetails>
<mapthishome>
http://www.zillow.com/homes/2115831629_zpid/</mapthishome>
<comparables>
http://www.zillow.com/homes/comps/2115831629_zpid/</comparables>
</links>
<address>
<street>411 Aldrich Ave</street>
<zipcode>30079</zipcode>
<city>Scottdale</city>
<state>GA</state>
<latitude>33.787872</latitude>
<longitude>-84.267332</longitude>
</address>
<FIPScounty>13089</FIPScounty>
<useCode>SingleFamily</useCode>
<yearBuilt>1915</yearBuilt>
<zestimate>
<amount currency="USD" />
<last-updated>12/31/1969</last-updated>
<oneWeekChange deprecated="true" />
<valueChange />
<valuationRange>
<low currency="USD" />
<high currency="USD" />
</valuationRange>
<percentile>0</percentile>
</zestimate>
<rentzestimate>
<amount currency="USD">785</amount>
<last-updated>03/11/2013</last-updated>
<oneWeekChange deprecated="true" />
<valueChange duration="30" currency="USD">7</valueChange>
<valuationRange>
<low currency="USD">589</low>
<high currency="USD">950</high>
</valuationRange>
</rentzestimate>
<localRealEstate>
<region id="43068" type="city" name="Scottdale">
<links>
<overview>
http://www.zillow.com/local-info/GA-Scottdale/r_43068/</overview>
<forSaleByOwner>
http://www.zillow.com/scottdale-ga/fsbo/</forSaleByOwner>
<forSale>
http://www.zillow.com/scottdale-ga/</forSale>
</links>
</region>
</localRealEstate>
</result>
</results>
</response>
</SearchResults:searchresults>
<!--
H:004 T:21ms S:1133 R:Wed Mar 13 08:51:11 PDT 2013 B:3.0.186358.20130311132712880-comp_rel_b.186358.20130311132846726-comp_rel_b
-->
这是我跑步时得到的字典print feedparser.parse('zillow.xml')
:
{'bozo': 0,
'encoding': u'utf-8',
'entries': [],
'feed': {u'SearchResults_searchresults': {'schemalocation': u'http://www.zillow.com/static/xsd/SearchResults.xsd http://www.zillowstatic.com/vstatic/15706ff87bd1719552647e4e6eb2b722/static/xsd/SearchResults.xsd',
'xsi:schemalocation': u'http://www.zillow.com/static/xsd/SearchResults.xsd http://www.zillowstatic.com/vstatic/15706ff87bd1719552647e4e6eb2b722/static/xsd/SearchResults.xsd'},
'amount': {'currency': u'USD'},
'high': {'currency': u'USD'},
'low': {'currency': u'USD'},
'oneweekchange': {'deprecated': u'true'},
'region': {'id': u'43068', 'name': u'Scottdale', 'type': u'city'},
'valuechange': {'currency': u'USD', 'duration': u'30'}},
'namespaces': {u'SearchResults': u'http://www.zillow.com/static/xsd/SearchResults.xsd',
u'xsi': u'http://www.w3.org/2001/XMLSchema-instance'},
'version': u''}
在这个例子中,我试图退出:Rent Estimate/Amount