I would like to read below XML and print the output in following order. Can you pls help with Query?

10 Subject1 A1 10 Subject2 B1 10 Subject3 C1 20 Subject1 B2 20 Subject2 A1 20 Subject3 C2
Thanks in advance
Here an example how you can query in the form you want:
XDocument doc = XDocument.Load("test.xml");
var query = from l in doc.Descendants("L1")
let id = l.Attribute("id").Value
from subject in l.Descendants("Subject")
select new
{
Id = id,
SubjectName = (string)subject.Attribute("SubjectName"),
Score = (string)subject.Attribute("Score")
};
foreach (var result in query)
{
Console.WriteLine(result);
}
Output:
{ Id = 10, SubjectName = Subject1, Score = A1 }
{ Id = 10, SubjectName = Subject2, Score = B1 }
{ Id = 10, SubjectName = Subject3, Score = C1 }
{ Id = 20, SubjectName = Subject1, Score = B2 }
{ Id = 20, SubjectName = Subject2, Score = A1 }
{ Id = 20, SubjectName = Subject3, Score = C2 }
(query).ToList().ForEach(item => Console.WriteLine(item)), substituting query with the linq query you suggested. ;)
Subject1 C1to come out of that XML?