c# google weather xml getting

本文关键字:getting xml weather google | 更新日期: 2023-09-27 18:33:10

我想从我使用这个http://www.google.com/ig/api?weather=获取天气

    // load xml result from Google weather
    var addr = WebUtility.HtmlEncode("http://www.google.com/ig/api?weather=vilnius&hl=lt");
    XDocument xd = XDocument.Load(addr);

// navigate to current conditions node
var current_conditions = from currentCond in xd.Root.Descendants("current_conditions")
select currentCond;
// navigate to Forecast info node
var forcastInfo = from forecastinfo in xd.Root.Descendants("forecast_information")
select forecastinfo;

我使用网址http://www.google.com/ig/api?weather=vilnius&hl=lt但信息是英文的,我找不到问题,请帮忙:)

c# google weather xml getting

请参阅我对原始问题的回答 - 不需要WebUtility.HtmlEncode,因为您将获得"amp;hl=lt"查询参数而不是"hl = lt"。

英语结果:http://www.google.com/ig/api?weather=vilnius&hl=lt

非英语结果:http://www.google.com/ig/api?weather=vilnius&hl=lt