Here is latest post from ScottGu’s blog. There he describes how to build a custom RSS Feed Reader using LINQ to XML. Check it out:
One of the big programming model improvements being made in .NET 3.5 is the work being done to make querying data a first class programming concept. We call this overall querying programming model “LINQ”, which stands for .NET Language Integrated Query.
LINQ supports a rich extensibility model that facilitates the creation of efficient domain-specific providers for data sources. .NET 3.5 ships with built-in libraries that enable LINQ support against Objects, XML, and Databases.
What is LINQ to XML?
LINQ to XML is a built-in LINQ data provider that is implemented within the “System.Xml.Linq” namespace in .NET 3.5.
LINQ to XML provides a clean programming model that enables you to read, construct and write XML data. You can use LINQ to XML to perform LINQ queries over XML that you retrieve from the file-system, from a remote HTTP URL or web-service, or from any in-memory XML content.
LINQ to XML provides much richer (and easier) querying and data shaping support than the low-level XmlReader/XmlWriter API in .NET today. It also ends up being much more efficient (and uses much less memory) than the DOM API that XmlDocument provides.
Using LINQ to XML to query a local XML File
To get a sense of how LINQ to XML works, we can create a simple XML file on our local file-system like below that uses a custom schema we’ve defined to store RSS feeds:
I could then use the new XDocument class within the System.Xml.Linq namespace to open and query the XML document above. Specifically, I want to filter the elements in the XML file and return a sequence of the non-disabled RSS feeds (where a disabled feed is a element with a “status” attribute whose value is “disabled”). I could accomplish this by writing the code below: