谷歌天气Api [英] Google weather Api
本文介绍了谷歌天气Api的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
public void wetter()
{
try
{
string ort; // ort = Location
ort = txtOrt.Text;
XmlDocument googlewetter = new XmlDocument();
googlewetter.Load(string.Format("http://www.google.com/ig/api?weather={0}", ort));
string stadt = googlewetter.SelectSingleNode("/xml_api_reply/weather/forecast_information/city").Attributes[0].InnerText;
lbStadt.Text = stadt;
string temperatur = googlewetter.SelectSingleNode("/xml_api_reply/weather/current_conditions/temp_c").Attributes[0].InnerText;
lbTemperatur.Text = temperatur;
string aktuell = googlewetter.SelectSingleNode("/xml_api_reply/weather/current_conditions/condition").Attributes[0].InnerText;
lbAktuell.Text = aktuell;
string wind = googlewetter.SelectSingleNode("/xml_api_reply/weather/current_conditions/wind_condition").Attributes[0].InnerText;
lbWind.Text = wind;
string luft = googlewetter.SelectSingleNode("/xml_api_reply/weather/current_conditions/humidity").Attributes[0].InnerText;
lbLuft.Text = luft;
}
catch
{
MessageBox.Show("Error");
}
}
private void button1_Click(object sender, EventArgs e)
{
wetter();
}
为什么输出语言总是英语?我想要德语.
Why is the output language always English? I want German.
推荐答案
您可以使用&hl =参数更改请求的语言.例如,http://www.google.com/ig/api?weather=london,england&hl=de将返回所有德语文本
You can change the language for the request using the &hl= parameter. For example http://www.google.com/ig/api?weather=london,england&hl=de will return all text in German
没有问题.开始调试.Windows窗体以英文显示了整个天气日期.浏览器(Firefox)中的日期为德语
No the problem is.. When i start debugging.. The windows form shows me the whole weather dates in english. The dates in the browser(Firefox) are in german
我刚刚尝试过 ^ ],并收到以下答复:
I just tried http://www.google.com/ig/api?weather=berlin,germany&hl=de&us=de[^] and received the following reply:
<xml_api_reply version="1">
<weather module_id="0" tab_id="0" mobile_row="0" mobile_zipped="1" row="0" section="0" >
<forecast_information>
<city data="Berlin, Berlin"/>
<postal_code data="berlin,germany"/>
<latitude_e6 data=""/>
<longitude_e6 data=""/>
<forecast_date data="2010-09-22"/>
<current_date_time data="2010-09-22 11:50:00 +0000"/>
<unit_system data="SI"/>
</forecast_information>
<current_conditions>
<condition data="Teils bewölkt"/>
<temp_f data="66"/>
<temp_c data="19"/>
<humidity data="Feuchtigkeit: 56 %"/>
<icon data="/ig/images/weather/partly_cloudy.gif"/>
<wind_condition data="Wind: SO mit 8 km/h"/>
</current_conditions>
<forecast_conditions>
<day_of_week data="Mi."/>
<low data="10"/>
<high data="19"/>
<icon data="/ig/images/weather/mostly_sunny.gif"/>
<condition data="Meist sonnig"/>
</forecast_conditions>
<forecast_conditions>
<day_of_week data="Do."/>
<low data="12"/>
<high data="21"/>
<icon data="/ig/images/weather/sunny.gif"/>
<condition data="Klar"/>
</forecast_conditions>
<forecast_conditions>
<day_of_week data="Fr."/>
<low data="13"/>
<high data="22"/>
<icon data="/ig/images/weather/chance_of_rain.gif"/>
<condition data="Vereinzelt Regen"/>
</forecast_conditions>
<forecast_conditions>
<day_of_week data="Sa."/>
<low data="10"/>
<high data="16"/>
<icon data="/ig/images/weather/chance_of_rain.gif"/>
<condition data="Vereinzelt Regen"/>
</forecast_conditions>
</weather>
</xml_api_reply>
您认为哪一部分不对?
Which is the part that you think is wrong?
这篇关于谷歌天气Api的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文