I'm trying to query a weather service and find the weather conditions at nearby airports.
Here is the XML: http://ift.tt/1ndQyCx
var document = XDocument.Load("http://ift.tt/1ndQyCx");
var airports =
from airport in
document.Descendants("response")
.Descendants("location")
.Descendants("nearby_weather_station")
.Descendants("airport")
.Descendants("station")
select
new Airport((string) airport.Element("city"), (string) airport.Element("state"),
(string) airport.Element("country"), (string) airport.Element("icao"),
(double) airport.Element("lat"), (double) airport.Element("lon"));
foreach (var airport in airports)
{
Console.WriteLine(airport.City);
}
Console.WriteLine(airports.Count());
But I am not getting anything printed to the console at all, and the airports.Count() always returns 0. What am I doing wrong?
No comments:
Post a Comment