Ads

Sunday, 7 December 2014

LINQ to XML


Functional Construction : Ability to create a XML document tree in a single statement.

Some classes of C# used to create XML document:

  1. XDocument : Used to create xml document
  2. XDeclaration: Used to create xml declaration
  3. XComment : Used to give comment
  4. XElement : To create root element or sub elements.
  5. XAttribute : To create attribute of elements

Code to create above XML document using C#:

3 - Query XML document using LINQ:

Lets retrieve students from above XML who have total marks more than 800 and sort in descending order.
4 - Modify XML document by LINQ to XML:



















Transfer XML to CSV file:
















No comments:

Post a Comment

Ads