因为需要获取了谷歌天气的api.xml文件,开始看到有点懵,怎么和常见的xml文件格式不一样呢?或许是我对xml的了解太少了吧,了解的博友给介绍一下。自习研读了它的xml文件之后,发现原来它的文件更加的容易解析,因为少了很多繁琐的东西。这时我获取的文件格式:
<xml_api_reply version="1"><weather module_id="0" tab_id="0" mobile_row="0" mobile_zipped="1" row="0" section="0"><forecast_information><city data="Beijing, Beijing"/><postal_code data="Beijing"/><latitude_e6 data=""/><longitude_e6 data=""/><forecast_date data="2012-03-20"/><current_date_time data="2012-03-20 23:00:00 +0000"/><unit_system data="SI"/></forecast_information><current_conditions><condition data="晴"/><temp_f data="51"/><temp_c data="11"/><humidity data="湿度: 25%"/><icon data="/ig/images/weather/sunny.gif"/><wind_condition data="风向: 西南、风速:3 米/秒"/></current_conditions><forecast_conditions><day_of_week data="周二"/><low data="2"/><high data="14"/><icon data="/ig/images/weather/mostly_sunny.gif"/><condition data="以晴为主"/></forecast_conditions><forecast_conditions><day_of_week data="周三"/><low data="6"/><high data="12"/><icon data="/ig/images/weather/mostly_sunny.gif"/><condition data="晴间多云"/></forecast_conditions><forecast_conditions><day_of_week data="周四"/><low data="3"/><high data="12"/><icon data="/ig/images/weather/mostly_sunny.gif"/><condition data="晴间多云"/></forecast_conditions><forecast_conditions><day_of_week data="周五"/><low data="1"/><high data="11"/><icon data="/ig/images/weather/mostly_sunny.gif"/><condition data="以晴为主"/></forecast_conditions></weather></xml_api_reply>
进行解析后得到天气信息:(界面比较丑,博友们使劲拍砖吧~~)

这里有一个问题,城市名称我始终没有得到中文的显示,其他的中英文都可以,就是城市名始终是英文,也就是拼音。知道的博友们给点建议吧。
另外最下方的时间和日期显示并lcd格式显示,使用的方法就是我前面文章里提到的,需要的博友看下这个小帖子。
获取系统当前时间,并以LED的形式显示
点击打开链接天气小图标也进行了处理,原来的图标不够圆滑,呵呵~~我进行了圆角处理,处理方法我也在前面的小帖子里提到,详情看这个:
iphone SDK:如何让一个方形的图片变成圆角?
我是使用ios提供的SAX进行文件解析的,具体的实现就暂不发布了,博友们应该理解。必要的时候我回发上来的。
本文详细解析了从谷歌天气API获取的XML文件格式,并分享了解析方法及遇到的问题解决方案,包括时间日期显示、城市名显示及图标处理。
656

被折叠的 条评论
为什么被折叠?



