基于Dragonbaord 410c开发板的Python交互设计(3)——天气预报xml数据解析
def prassWeatherInfo(self,weatherXml):
print("start prassWeatherInfo")
while not weatherXml.atEnd():
if weatherXml.hasError():
print ("error: get weather data error")
return -1
elif weatherXml.isStartElement():
if weatherXml.name()=="city":
self.weather_city = weatherXml.readElementText()
#print(city)
weatherXml.readNext()
elif weatherXml.name()=="updateTIme":
self.weahter_updateTIme=weatherXml.readElementText()
weatherXml.readNext()
elif weatherXml.name()=="wendu":
self.weather_wendu=weatherXml.readElementText()
weatherXml.readNext()
elif weatherXml.name()=="fengli":
self.weather_fengli=weatherXml.readElementText()
weatherXml.readNext()
elif weatherXml.name()=="shidu":
self.weather_shidu=weatherXml.readElementText()
weatherXml.readNext()
elif weatherXml.name()=="fengxiang":
self.weather_fengxiang=weatherXml.readElementText()
weatherXml.readNext()
elif weatherXml.name()=="sunrise_1":
self.weather_sunrise=weatherXml.readElementText()
weatherXml.readNext()
elif weatherXml.name()=="sunset_1":
self.weather_sunset=weatherXml.readElementText()
DragonBoard 410c python XML 相关文章: