Unable to Select in LINQ to XML, error: Object reference not set to an instance of an object -
I'm new to using Linq for XML and I have to go through a troublesome error. When trying to drag in my XML file, I get an error that "object reference is not set to an instance of an object." And it is saying that this error is because I am trying to choose a new statement. I've attached my code below: using the system; Using System.Collections.Generic; Using System.Linq; Using System.Web; Using System.Web.UI; Using System.Web.UI.WebControls; Using System.Xml.Linq; Public Partial Class _Default: System.Web.UI.Page {Secure Zero Page_load (Object Sender, EventArgs E) {XDocument feed = XDocument.Load (Server.MapPath ("VEHICLES.XML")); Var query = c to feed.Descendants ("vehicle") where (string) c.Element ("VehicleType"). Select value == "0" new {Vin = c.Element ("Vin"). Value, condition = c. Element ("vehicle type"). Value, year = c. Element ("year"). Values}; CarLister.DataSource = Query; CarLis...