Creating Sample XML using LINQ
In LINQ to XML we have XElement and XAttribute object constructors to create XML Document. XElement will be used to create Element and XAttribute will be used to add attribute(s) to the element.
Let us consider an example to create a XML which contians the Employee details.
The example contains Employees as root element, Employee as sub element. The employee details like EmployeeID, Salary as Attributes, and Department, Date of Joining(DOJ) as sub element to Employee element.