Skip to content

Instantly share code, notes, and snippets.

@DavidSSL
Last active December 17, 2015 09:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DavidSSL/8ff401eeea64cfab4584 to your computer and use it in GitHub Desktop.
Save DavidSSL/8ff401eeea64cfab4584 to your computer and use it in GitHub Desktop.
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