【发布时间】:2013-02-18 08:53:49
【问题描述】:
这是我目前所拥有的。我试图从 URL 中读取 XML 并获取例如温度、湿度……等等……但是每次我尝试其他方法时都会出现错误。我想检索信息并将其放入标签中。
namespace WindowsFormsApplication1 {
public partial class Form1: Form {
public Form1() {
InitializeComponent();
}
private void btnSubmit_Click(object sender, EventArgs e) {
String zip = txtZip.Text;
XmlDocument weatherURL = new XmlDocument();
weatherURL.Load("http://api.wunderground.com/api/"
your_key "/conditions/q/" + zip + ".xml");
foreach(XmlNode nodeselect in weatherURL.SelectNodes("response/current_observation"));
}
}
}
【问题讨论】:
-
显示 XML 的外观示例以及您尝试从中解析的精确信息。
-
“它给了我一个错误”是永远不够的信息 - 请参阅tinyurl.com/so-list
-
0.1 wunderground.com/weather/api/d/terms.html</…多云 72 F (22.2 C)