http://wthrcdn.etouch.cn/WeatherApi?city=%E5%8C%97%E4%BA%AC 可以查詢北京的天氣。city=后面是城市的名字,此處為北京。
獲取XML數據的C#代碼
WebRequest request = WebRequest.Create("http://wthrcdn.etouch.cn/WeatherApi?city=%E5%8C%97%E4%BA%AC");WebResponse response = request.GetResponse();GZipStream GStream = new GZipStream(response.GetResponseStream(), ComPRessionMode.Decompress, true);StreamReader reader = new StreamReader(GStream, Encoding.UTF8);string str = reader.ReadToEnd();reader.Close();response.Close();str即為獲取的XML格式天氣信息。通過后續XML解析獲取數據。
這個天氣api給的信息比較詳細。附一張測試程序截圖。

代碼通過Visual Studio 2015測試。
新聞熱點
疑難解答