我正在解析以下XML字符串:
-<places>
-<place place_id="11703">
<gas_price update_time="2017-06-21 00:00:00" type="premium">17.51</gas_price>
</place>
我已经能够提取地点ID并将价格放在溢价下的标题中,但是我无法提取时间。这是我的代码:
stationid=member.attrib.get('place_id')
servicestationprices.append(stationid)
regular_price=member.findtext("./gas_price[@type='regular']")
servicestationprices.append(regular_price)
premium_price=member.findtext("./gas_price[@type='premium']")
servicestationprices.append(premium_price)
diesel_price=member.findtext("./gas_price[@type='diesel']")
servicestationprices.append(diesel_price)
#regular_time=member.element("regular time",f='regular']")
#servicestationprices.append(regular_time)
#servicestationprices.append(regulartime)
我用#标记的那些是我尝试过的,但那些不起作用。任何建议将不胜感激。感谢。