wp7天气预报源代码(二序列化谷歌数据)公布源代码下载地址
2012-03-27 22:32
716 查看
在上一篇文章里已经介绍了这个应用
文章源地址:/article/5646431.html
由于代码过多,和繁杂的前台页面效果代码,没办法在博文中说明白,还有很多网友要求我公布源代码项目。在文章的最下面我提供了源代码的下载地址。
作者QQ:29992379
这个天气预报用的是谷歌的API,我特意写了个工具类用来序列化返回的数据,本文中主要介绍这个工具类。
代码如下:
整个天气预报项目源代码的下载地址:http://download.csdn.net/detail/wildfeng04/4168595
在以后的博文里我会详细讲解这个应用UI方面的实现,毕竟这个应用亮点全在UI上面。我个人是这么理解的,因为功能代码不是很难,UI的效果比较炫。我用了Storyboard来实现了一些效果。
原文中地址:/article/5646434.html
文章源地址:/article/5646431.html
由于代码过多,和繁杂的前台页面效果代码,没办法在博文中说明白,还有很多网友要求我公布源代码项目。在文章的最下面我提供了源代码的下载地址。
作者QQ:29992379
这个天气预报用的是谷歌的API,我特意写了个工具类用来序列化返回的数据,本文中主要介绍这个工具类。
代码如下:
public static class GoogleWeatherHelper { /// <summary> /// 获取城市以及省 /// </summary> /// <param name="xmlWeather">xml数据</param> /// <returns></returns> public static string GetCity(XElement xmlWeather) { XElement forecast_information = xmlWeather.Descendants("forecast_information").First(); return forecast_information.Element("city").Attribute("data").Value; } /// <summary> /// 获取中文城市名称 /// </summary> /// <param name="xmlWeather"></param> /// <returns></returns> public static string GetPostalCode(XElement xmlWeather) { XElement forecast_information = xmlWeather.Descendants("forecast_information").First(); return forecast_information.Element("postal_code").Attribute("data").Value; } /// <summary> /// 获取预报的日期 /// </summary> /// <param name="xmlWeather"></param> /// <returns></returns> public static string GetForecastDate(XElement xmlWeather) { XElement forecast_information = xmlWeather.Descendants("forecast_information").First(); return forecast_information.Element("forecast_date").Attribute("data").Value; } /// <summary> /// 获取湿度 /// </summary> /// <param name="xmlWeather"></param> /// <returns></returns> public static string GetHumidity(XElement xmlWeather) { XElement forecast_information = xmlWeather.Descendants("current_conditions").First(); return forecast_information.Element("humidity").Attribute("data").Value; } /// <summary> /// 获取风向 /// </summary> /// <param name="xmlWeather"></param> /// <returns></returns> public static string GetWindCondition(XElement xmlWeather) { XElement forecast_information = xmlWeather.Descendants("current_conditions").First(); return forecast_information.Element("wind_condition").Attribute("data").Value; } /// <summary> /// 获取今天星期 /// </summary> /// <param name="xmlWeather"></param> /// <returns></returns> public static string GetTodayWeek(XElement xmlWeather) { XElement forecast_information = xmlWeather.Descendants("forecast_conditions").First(); return forecast_information.Element("day_of_week").Attribute("data").Value; } /// <summary> /// 获取今天最低温度 /// </summary> /// <param name="xmlWeather"></param> /// <returns></returns> public static string GetTodayLow(XElement xmlWeather) { XElement forecast_information = xmlWeather.Descendants("forecast_conditions").First(); return forecast_information.Element("low").Attribute("data").Value; } /// <summary> /// 获取今天最高温度 /// </summary> /// <param name="xmlWeather"></param> /// <returns></returns> public static string GetTodayHight(XElement xmlWeather) { XElement forecast_information = xmlWeather.Descendants("forecast_conditions").First(); return forecast_information.Element("high").Attribute("data").Value; } /// <summary> /// 获取今天天气图标 /// </summary> /// <param name="xmlWeather"></param> /// <returns></returns> public static string GetTodayIcon(XElement xmlWeather) { XElement forecast_information = xmlWeather.Descendants("forecast_conditions").First(); return ExtractFileName(forecast_information.Element("icon").Attribute("data").Value); } /// <summary> /// 获取今天天气情况 /// </summary> /// <param name="xmlWeather"></param> /// <returns></returns> public static string GetTodayCondition(XElement xmlWeather) { XElement forecast_information = xmlWeather.Descendants("forecast_conditions").First(); return forecast_information.Element("condition").Attribute("data").Value; } /// <summary> /// 获取明天星期 /// </summary> /// <param name="xmlWeather"></param> /// <returns></returns> public static string GetTomorrowWeek(XElement xmlWeather) { XElement forecast_information = xmlWeather.Descendants("forecast_conditions").ElementAt(1); return forecast_information.Element("day_of_week").Attribute("data").Value; } /// <summary> /// 获取明天最低温度 /// </summary> /// <param name="xmlWeather"></param> /// <returns></returns> public static string GetTomorrowLow(XElement xmlWeather) { XElement forecast_information = xmlWeather.Descendants("forecast_conditions").ElementAt(1); return forecast_information.Element("low").Attribute("data").Value; } /// <summary> /// 获取明天最高温度 /// </summary> /// <param name="xmlWeather"></param> /// <returns></returns> public static string GetTomorrowHight(XElement xmlWeather) { XElement forecast_information = xmlWeather.Descendants("forecast_conditions").ElementAt(1); return forecast_information.Element("high").Attribute("data").Value; } /// <summary> /// 获取明天天气图标 /// </summary> /// <param name="xmlWeather"></param> /// <returns></returns> public static string GetTomorrowIcon(XElement xmlWeather) { XElement forecast_information = xmlWeather.Descendants("forecast_conditions").ElementAt(1); return ExtractFileName(forecast_information.Element("icon").Attribute("data").Value); } /// <summary> /// 获取明天天气情况 /// </summary> /// <param name="xmlWeather"></param> /// <returns></returns> public static string GetTomorrowCondition(XElement xmlWeather) { XElement forecast_information = xmlWeather.Descendants("forecast_conditions").ElementAt(1); return forecast_information.Element("condition").Attribute("data").Value; } /// <summary> /// 获取后天星期 /// </summary> /// <param name="xmlWeather"></param> /// <returns></returns> public static string GetHouTianWeek(XElement xmlWeather) { XElement forecast_information = xmlWeather.Descendants("forecast_conditions").ElementAt(2); return forecast_information.Element("day_of_week").Attribute("data").Value; } /// <summary> /// 获取后天最低温度 /// </summary> /// <param name="xmlWeather"></param> /// <returns></returns> public static string GetHouTianLow(XElement xmlWeather) { XElement forecast_information = xmlWeather.Descendants("forecast_conditions").ElementAt(2); return forecast_information.Element("low").Attribute("data").Value; } /// <summary> /// 获取后天最高温度 /// </summary> /// <param name="xmlWeather"></param> /// <returns></returns> public static string GetHouTianHight(XElement xmlWeather) { XElement forecast_information = xmlWeather.Descendants("forecast_conditions").ElementAt(2); return forecast_information.Element("high").Attribute("data").Value; } /// <summary> /// 获取后天天气图标 /// </summary> /// <param name="xmlWeather"></param> /// <returns></returns> public static string GetHouTianIcon(XElement xmlWeather) { XElement forecast_information = xmlWeather.Descendants("forecast_conditions").ElementAt(2); return ExtractFileName(forecast_information.Element("icon").Attribute("data").Value); } /// <summary> /// 获取后天天气情况 /// </summary> /// <param name="xmlWeather"></param> /// <returns></returns> public static string GetHouTianCondition(XElement xmlWeather) { XElement forecast_information = xmlWeather.Descendants("forecast_conditions").ElementAt(2); return forecast_information.Element("condition").Attribute("data").Value; } /// <summary> /// 获取大后天星期 /// </summary> /// <param name="xmlWeather"></param> /// <returns></returns> public static string GetDaHouTianWeek(XElement xmlWeather) { XElement forecast_information = xmlWeather.Descendants("forecast_conditions").ElementAt(3); return forecast_information.Element("day_of_week").Attribute("data").Value; } /// <summary> /// 获取大后天最低温度 /// </summary> /// <param name="xmlWeather"></param> /// <returns></returns> public static string GetDaHouTianLow(XElement xmlWeather) { XElement forecast_information = xmlWeather.Descendants("forecast_conditions").ElementAt(3); return forecast_information.Element("low").Attribute("data").Value; } /// <summary> /// 获取大后天最高温度 /// </summary> /// <param name="xmlWeather"></param> /// <returns></returns> public static string GetDaHouTianHight(XElement xmlWeather) { XElement forecast_information = xmlWeather.Descendants("forecast_conditions").ElementAt(3); return forecast_information.Element("high").Attribute("data").Value; } /// <summary> /// 获取大后天天气图标 /// </summary> /// <param name="xmlWeather"></param> /// <returns></returns> public static string GetDaHouTianIcon(XElement xmlWeather) { XElement forecast_information = xmlWeather.Descendants("forecast_conditions").ElementAt(3); return ExtractFileName(forecast_information.Element("icon").Attribute("data").Value); } /// <summary> /// 获取大后天天气情况 /// </summary> /// <param name="xmlWeather"></param> /// <returns></returns> public static string GetDaHouTianCondition(XElement xmlWeather) { XElement forecast_information = xmlWeather.Descendants("forecast_conditions").ElementAt(3); return forecast_information.Element("condition").Attribute("data").Value; } private static string ExtractFileName(string fullFileName) { string str = fullFileName.Substring(fullFileName.LastIndexOf('/') + 1); return str.Substring(0, str.LastIndexOf('.')).Replace("cn_", ""); } }
整个天气预报项目源代码的下载地址:http://download.csdn.net/detail/wildfeng04/4168595
在以后的博文里我会详细讲解这个应用UI方面的实现,毕竟这个应用亮点全在UI上面。我个人是这么理解的,因为功能代码不是很难,UI的效果比较炫。我用了Storyboard来实现了一些效果。
原文中地址:/article/5646434.html
相关文章推荐
- wp7天气预报源代码(二序列化谷歌数据)公布源代码下载地址
- wp7天气预报源代码(二获取谷歌天气数据)公布源代码下载地址
- .net下两种json序列化速度比对(已添加源代码下载地址)
- wp7天气预报源代码(三UI的制作)下载地址更新
- Net网络通讯编程[利用Socket实现字串、文件、序列化对象传输]--前面6篇博文全部源代码下载地址
- 重磅 | 谷歌发布免费GNSS数据分析工具【内附下载地址】
- 谷歌大数据三大论文(中英文下载地址)
- Net网络通讯编程[利用Socket实现字串、文件、序列化对象传输]--前面6篇博文全部源代码下载地址
- .net下两种json序列化速度比对(已添加源代码下载地址)
- Google Earth Browser Plugin (谷歌 地球 浏览器 插件) 下载地址 5.0
- Wp7客户端与Webservice的数据传输,json的序列化与反序列化
- 利用javascript从数据库取数据来实现CSDN首页图片的切换效果(新增下载地址)
- 遥感数据下载地址
- CSDN数据库下载地址 CSDN 用户名密码泄漏,600万数据下载
- Aspose Cells 控件如何实现数据过滤(附代码和下载地址)
- CSBlogV1 源代码公布下载
- sqlite数据下载链接地址
- EXCEL2010数据挖掘插件 下载地址
- xwork的源代码下载地址
- MyEclipse7.0 注册码 序列号 Java版注册机源代码 MyEclipse7.0 下载地址