私はhttp://api.met.no/weatherapi/locationforecast/1.9/?lat=49.8197202;lon=18.1673554 XMLを処理しようとしています。 各温度要素のすべての値属性を選択したいとします。C#XmlDocument選択ノードが空に戻ります
私はこれを試しました。
const string url = "http://api.met.no/weatherapi/locationforecast/1.9/?lat=49.8197202;lon=18.1673554";
WebClient client = new WebClient();
string x = client.DownloadString(url);
XmlDocument xml = new XmlDocument();
xml.LoadXml(x);
XmlNodeList nodes = xml.SelectNodes("/weatherdata/product/time/location/temperature");
//XmlNodeList nodes = xml.SelectNodes("temperature");
foreach (XmlNode node in nodes)
{
Console.WriteLine(node.Attributes[0].Value);
}
しかし、私はいつも何も得られません。何が間違っているのですか?
あなたの文書にこのメモが存在しない可能性があります。 XDocument – mybirthname
も使用してください。私はXmlDocumentクラスを使用する必要があります。私は学校のプロジェクトとその必要な指定のためにそれを行う必要があります。 – gygabyte