Querying XML

While using LINQ on an XML file, we use the XDocument class to load the XML as a string in the memory.

Until LINQ was introduced in .NET, developers used to work with the XmlDocument helper class to do operations on the XML file. XDocument is a similar helper class that we use in LINQ for doing operations on the XML file. Using LINQ for such xml operations not only helps to provide a consistent query experience but also increases the overall performance of the application. The XDocument class contains the following elements:

  • XDeclaration: This component signifies information in regards to XmlDeclaration and contains information such as XML version and the encoding used.
  • XElement: This component signifies the root node or object ...

Get Programming in C#: Exam 70-483 (MCSD) Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.