Ejemplo n.º 1
0
        /// <summary>
        /// 根据名称获取天气
        /// </summary>
        /// <param name="cityName"></param>
        /// <returns></returns>
        public WeatherInfo GetWeatherInfo(string cityName)
        {
            var url         = "http://wthrcdn.etouch.cn/WeatherApi";
            var parameters2 = new Dictionary <string, string>();

            parameters2.Add("city", cityName);
            var weatherXML  = _http.HttpSend(url, parameters2, "post").ToString();
            var weatherInfo = new WeatherInfo();
            var doc         = new XmlDocument();

            doc.LoadXml(weatherXML);
            var weatherJson = JsonMethod.XmlToJSON(doc);

            weatherInfo = JsonMethod.JsonToModel <WeatherInfo>(weatherJson);

            return(weatherInfo);
        }