XML
Finally, we’ve arrived back with hierarchical data stored in the form of XML. The new System.Xml.Linq
APIs, also known as LINQ to XML, make dealing with XML data much easier, too. In fact, LINQ to XML is LINQ to Objects in disguise, providing a way for XML data to be represented using IEnumerable
sequences. This is achieved by providing various methods that enumerate over the XML data in different ways. For example, methods exist that go over the children of a node, others go over elements or attributes only, and yet other methods recursively visit all descendants.
Starting from the same XML document, we’ll formulate some queries using LINQ to show how those methods are used to represent various enumeration strategies over the XML data:
Get C# 5.0 Unleashed 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.