LINQ Cookbook, Recipe 8: Querying XML Using LINQ (Doug Rothaus)

Ingredients:

·         Visual Studio 2008 (Beta2 or Higher)

 

Categories: LINQ-To-XML

 

Instructions:

·         Create a new Console Application in Visual Basic.

·         Create an RSS document. Add the following code to Sub Main.

    Dim rss = <?xml version=1.0?>

              <rss version=2.0>

                <channel>

                  <title>LINQ to XML in Visual Basic</title>

                  <description>Sample RSS Feed</description>

                  <language>en-us</language>

                  <pubDate>Tue, 18 Sep 2007 00:56:12 GMT</pubDate>

                  <item>

                    <title>Basic Instincts: Lambda Expressions</title>

                    <description>A new feature added to Visual Basic 9 to

                                 support Language Integrated Queries (LINQ),

                                 which adds data programmability to

                                 Visual Basic.</description>

                    <pubDate>Thu, 27 Sep 2007 23:54:55 GMT</pubDate>

                  </item>

                  <item>

                    <title>Visual Basic Pack for Visual Studio 2005 SDK</title>

                    <description>The Visual Basic Pack for the Visual Studio

                                 2005 SDK includes SDK samples converted into

                                 the Visual Basic language and a new wizard for

                                 generating Visual Basic-based integration

                                 packages for Visual Studio.</description>

                    <pubDate>Mon, 17 Sep 2007 23:58:49 GMT</pubDate>

                  </item>

                  <item>

                    <title>XML to Schema Tool</title>

                    <description>The XML to Schema tool is a free project item

                                 template to automate creation of XML schema

                                 sets from any number of XML documents. If you

                                 are working with Language Integrated Queries

                                 (LINQ) to XML in Visual Basic 9, this utility

                                 can significantly improve your editing

                                 experience by adding XML schemas (.xsd files)

                                 to your project that add IntelliSense for XML

                                 properties.</description>

                    <pubDate>Mon, 17 Sep 2007 23:59:43 GMT</pubDate>

                  </item>

                  <item>

                    <title>Line and Shape Controls in the Power Packs</title>

                    <description>Download the latest version of the Visual

                                 Basic 2005 Power Packs which now includes Line

                                 and Shape controls that enable you to draw

                                 lines, ovals, and rectangles on forms and

                                 containers at design time making it much easier

                                 to enhance the look of your user

                                 interface.</description>

                    <pubDate>Mon, 20 Aug 2007 20:24:25 GMT</pubDate>

                  </item>

                </channel>

              </rss>