这是我试过自己的代码。链接列表数据应显示在datagridview上。但我从代码的2个链接收到错误,请尝试解决此问题 Maxtemp和Max临时天气等级
city = txttext.Text;
string uri = string.Format("http://api.apixu.com/v1/forecast.xml?={0}&days=1 ", city);
XDocument doc = XDocument.Load(uri);
List<weather> we = new List<weather>();
we.Add(new weather() { Maxtemp = (string)doc.Descendants("maxtemp_c").FirstOrDefault()});
we.Add(new weather() { Mixtemp = (string)doc.Descendants("mixtemp_c").FirstOrDefault()});
dataGridView1.DataSource = we;
这是我现在添加的天气类文件,我希望它能解决这个问题 感谢
class weather
{
private string date;
private string maxtemp;
private string mintemp;
private string maxwindmph;
private string maxwindkph;
private string humidity;
public weather(string maxtemp, string mintemp, string maxwindmph, string maxwindkph, string humidity)
{
this.maxtemp = maxtemp;
this.mintemp = mintemp;
this.maxwindmph = maxwindmph;
this.maxwindkph = maxwindkph;
this.humidity = humidity;
}
public string Maxtemp
{
get { return maxtemp; }
set { maxtemp = value; }
}
public string Mintemp
{
get { return mintemp; }
set { mintemp = value; }
}
public string Maxwindmph
{
get { return maxwindmph; }
set { maxwindmph = value; }
}
public string Humidity
{
get { return humidity; }
set { humidity = value; }
}
}
}