In this question, if I need to get "date" included in the output, what changes should be made?
When I included
let dt = l.Element("Date").Value
It gives, "Object reference not set to an instance of an object"
var query = from l in doc.Descendants("L1")
let dt = l.Element("Date").Value
let id = l.Attribute("id").Value
from subject in l.Descendants("Subject")
select new
{
Date = dt,
Id = id,
SubjectName = (string)subject.Attribute("SubjectName"),
Score = (string)subject.Attribute("Score")
};
foreach (var result in query)
{
Console.WriteLine(result);
}