Beispiel #1
0
        private void UpdateForZipCode(IWeatherService weatherService, string zipCode)
        {
            string xmlBuffer = weatherService.GetConditionsForZipCode(zipCode);

            var xmlDocument = new XmlDocument();
            xmlDocument.LoadXml(xmlBuffer);

            var node_response = xmlDocument.FirstChild;
            var node_currentObservation = node_response["current_observation"];
            {
                Temperature = double.Parse(node_currentObservation["temp_c"].InnerText);
                WindSpeed = double.Parse(node_currentObservation["wind_kph"].InnerText);

                var node_displayLocation = node_currentObservation["display_location"];
                {
                    Location = new WeatherLocation();
                    Location.City = node_displayLocation["city"].InnerText;
                    Location.State = node_displayLocation["state"].InnerText;
                    Location.Country = node_displayLocation["country"].InnerText;
                    Location.Elevation = (int)double.Parse(node_displayLocation["elevation"].InnerText);
                }
            }
        }