c# google weather xml getting

你离开我真会死。 提交于 2019-12-25 17:34:29

问题


i want get weather from http://www.google.com/ig/api?weather= I use this

    // 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;

I use url http://www.google.com/ig/api?weather=vilnius&hl=lt but information get in english, I can't find problem please help :)


回答1:


See my answer to your original question - no need for WebUtility.HtmlEncode as you get "amp;hl=lt" query parameter instead of "hl=lt".

English result: http://www.google.com/ig/api?weather=vilnius&hl=lt

Non-English result:http://www.google.com/ig/api?weather=vilnius&hl=lt



来源:https://stackoverflow.com/questions/10455776/c-sharp-google-weather-xml-getting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!