[英]weather API forecast system in c#
i want to display 7 days of the weeks. 我想显示一周的7天。 weather information this is api i used to for getting 7 days result of london 天气信息,这是我用来获取伦敦7天结果的api
http://api.apixu.com/v1/forecast.xml?key=[APIKEY]&q=india&days=7
if i write code in c# below i should be no problem 如果我在下面的C#中编写代码,我应该没问题
StringBuilder sb = new StringBuilder();
sb.Append("http://api.apixu.com/v1/forecast.xml?key=[APIKEY]&q=");
sb.Append(txtbox.Text);
sb.Append("&days=");
sb.Append("7");
this is code i written to display on data grid view but no result display can any one fix the code for me to display 7 days weather information will display on data grid view 这是我编写的要在数据网格视图上显示的代码,但没有结果显示可以修复该代码以让我显示7天的天气信息,该代码将在数据网格视图上显示
XmlReader xmlFile;
xmlFile = XmlReader.Create(sb);
DataSet ds = new DataSet();
ds.ReadXml(xmlFile);
dataGridView1.DataSource = ds.Tables[0];
Just ToString()
the StringBuilder
: 只是ToString()
这个StringBuilder
:
XmlReader xmlFile;
xmlFile = XmlReader.Create(sb.ToString());
DataSet ds = new DataSet();
ds.ReadXml(xmlFile);
You might want to however checkout HttpClient
as consuming a web service with XmlReader.Create
feels just plain dirty 但是,您可能希望将HttpClient
检出为使用XmlReader.Create
服务使用。
https://dotnetfiddle.net/ZSTOhq https://dotnetfiddle.net/ZSTOhq
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.