LINQ to XML Code Review

Define the Person XML File

Code Download

  • Download Description:linq to xml download
  • .NET Framework:3.5
  • .NET Language:C#
  • Date Published:2009-07-01
  • Download Size:11 KB

Code Review

Code Walkthrough

The below XML is stored in the People.xml file and is used to specify person data to be queried using LINQ to XML.

<?xml version="1.0" encoding="utf-8" ?> <people> <person> <id>1</id> <firstname>Carl</firstname> <lastname>Lewis</lastname> <idrole>1</idrole> </person> <person> <id>2</id> <firstname>Tom</firstname> <lastname>Gray</lastname> <idrole>2</idrole> </person> <person> <id>3</id> <firstname>Mary</firstname> <lastname>Grant</lastname> <idrole>2</idrole> </person> <person> <id>4</id> <firstname>Fabio Claudio</firstname> <lastname>Ferracchiati</lastname> <idrole>1</idrole> </person> <role> <id>1</id> <roledescription>Manager</roledescription> </role> <role> <id>2</id> <roledescription>Developer</roledescription> </role> <salary> <idperson id="1" year="2004" salaryyear="10000,0000" /> <idperson id="1" year="2005" salaryyear="15000,0000" /> </salary> </people>