Skip to content

Instantly share code, notes, and snippets.

@DavidSSL
Last active Dec 17, 2015
Embed
What would you like to do?
var document = XElement.Load("file.xml");
return
document.Descendants("patient")
.Where(e => e.Attribute("id").Value == "1")
.Select(e => new PatientRecord
{
FirstName = e.Attribute("firstName").Value
,
LastName = e.Attribute("lastName").Value
,
ExamFindings = e.Descendants("exam")
.OrderByDescending(child => (DateTime)child.Attribute("date"))
.Select(child => new Exam
{
Date = DateTime.Parse(child.Attribute("date").Value)
,
Findings = child.Value
})
})
.Single();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment