I'm getting the NRE error that says: "Object reference not set to an instance of an object."
From the following code:
select new
{
ICAO = station.Element("icao").Value,
};
The entire script is:
XDocument xmlDoc = XDocument.Load(@"http://api.wunderground.com/auto/wui/geo/GeoLookupXML/index.xml?query=94107");
var stations = from station in xmlDoc.Descendants("station")
select new
{
ICAO = station.Element("icao").Value,
};
lblXml.Text = "";
foreach (var station in stations)
{
lblXml.Text = lblXml.Text + "ICAO: " + station.ICAO + "<br />";
}
if (lblXml.Text == "")
lblXml.Text = "No Results.";
}
I don't understand why it isn't creating the station object and setting the ICAO value. Any ideas/tips for future XML and C# reference?