Linq cast convertion Xelement error

I'm attemping to parse an xml document as follows\[code\] var locs = from node in doc.Descendants("locations") select new { ID = (double)Convert.ToDouble(node.Attribute("id")), File = (string)node.Element("file"), Location = (string)node.Element("location"), Postcode = (string)node.Element("postCode"), Lat = (double)Convert.ToDouble(node.Element("lat")), Lng = (double)Convert.ToDouble(node.Element("lng")) }; \[/code\]I'm getting the error: \[quote\] Unable to cast object of type 'System.Xml.Linq.XElement' to type 'System.IConvertible'.\[/quote\]When I check the value of node I'm getting all the elements from the locations children properly, but it doesn't want to break it up for me. I've checked errors similar to this but can't figure out what I am doing wrong. Any suggestions?
 
Back
Top