The System.Xml.Linq namespace offers an easily and efficiently way to create, read and modify XML documents. Within this article I want to show you the basic concept to create and read a XML document.

Create a XML document

In this example application a list of persons should be written into a XML document. Each person has a first name and last name property. Furthermore an id property exists. The XML element of one person should contain the identifier as attribute and two sub elements with the name properties.

At next the previously created file should be read. The following source code shows an according example. Please note that the example does not contain any error handling. Within your projects you should add try-catch statements.