基于Dragonbaord 410c开发板的Python交互设计(3)——天气预报xml数据解析
#print("value")
weatherXml.readNext()
elif weatherXml.name()=="detail":
self.weather_zhishu_data.append(weatherXml.readElementText())
#print("detail")
#print(weatherXml.readElementText())
weatherXml.readNext()
else:
weatherXml.readNext()
else:
weatherXml.readNext()
break
else:
weatherXml.readNext()
else:
weatherXml.readNext()
break
else:
weatherXml.readNext()
else:
weatherXml.readNext()
weatherXml.clear()
self.updateOK=1
for i in range(0,5):
print(self.weather_zhishu_name[i])
print(self.weather_zhishu_vale[i])
print(self.weather_zhishu_data[i])
def updateOK(self):
return self.updateOK
通过调用该类就可以实现对xml文件中个的天气数据的解析,并且通过访问类成员就可以获取相应的天气信息。
如下图所示,是调用该类解析得到的天气指数数据:
以上就是整个天气xml数据解析的过程,后期blog中我将用该类来实现天气demo中的xml数据解析,并且在dragon
DragonBoard 410c python XML 相关文章: