public Conditions GetCurrentConditions(string location) { Conditions conditions = new Conditions(); XmlDocument xmlConditions = new XmlDocument(); xmlConditions.Load(string.Format("http://www.google.com/ig/api?weather={0}", location)); if (xmlConditions.SelectSingleNode("xml_api_reply/weather/problem_cause") != null) { conditions = null; } else { conditions.City = xmlConditions.SelectSingleNode("/xml_api_reply/weather/forecast_information/city").Attributes["data"].InnerText; conditions.Condition = xmlConditions.SelectSingleNode("/xml_api_reply/weather/current_conditions/condition").Attributes["data"].InnerText; conditions.TempC = xmlConditions.SelectSingleNode("/xml_api_reply/weather/current_conditions/temp_c").Attributes["data"].InnerText; conditions.TempF = xmlConditions.SelectSingleNode("/xml_api_reply/weather/current_conditions/temp_f").Attributes["data"].InnerText; conditions.Humidity = xmlConditions.SelectSingleNode("/xml_api_reply/weather/current_conditions/humidity").Attributes["data"].InnerText; conditions.Wind = xmlConditions.SelectSingleNode("/xml_api_reply/weather/current_conditions/wind_condition").Attributes["data"].InnerText; } return conditions; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)