Visual Studio Toolbox: Using LINQ to XML to Query Data on the Web

Download this episode

Download Video


These days, Web sites are providing access to a large amount of data, everything from RSS feeds to pictures to movie titles and more. Often, all you need to do in an application is send an HTTP request to a Web site. The Web site sends the data back via XML, and the easiest way to work with that data is to use LINQ queries. In this episode, Robert shows you how to use LINQ to XML to make sense of the XML data a Web site sends you. He gives  examples of working with an RSS feed, retrieving images from Flickr, querying for wineries and wines using, and returning movies from NetFlix. You'll see basic queries, see how to retrieve data from elements and attributes, and see how to work with namespaces.

Check out Robert's blog for all the code he used in this episode.



Available formats for this video:

Actual format may change based on video formats available and browser capability.

    The Discussion

    • User profile image
      Another nice episode. Good work! Thanks Robert.
    • User profile image

      Waiting for the next episode you announced (using Linq to XML to write XML instead of querying).
      Great job!

    • User profile image

      Good show but lets not waste time with VB examples. Wink

    • User profile image

      Many answered about what we want to see but you do not listen to what we say.

      Lets try one more time:
      We want to see C++11 with visual studio using GCC and clang.

      Do you refuse to listen because the compiler we want to use is GCC which is not a microsoft product ?

    • User profile image

      Waiting for the next episode you announced (using Linq to XML to write XML instead of querying).
      Great job!


    • User profile image

      Great episode Robert. As JSON is becoming more popular than XML due to it's smaller size, what about a show on LINQ to JSON? I see there are some frameworks out there that can do this. What about a show on this?

    • User profile image

      this man looks like justin huffman...

    • User profile image

      @peter: I hope that is a complement! Smiley

    • User profile image

      Great examples
      I wish I had this months ago.

    • User profile image

      Just watched this on the bus ride into work.  Excellent!

    • User profile image

      Great show. I would love to see more feature deep dive episodes. Thanks for putting this together.

    • User profile image

      I like this style of deep dive, but I have one remark.

      Never use the query operator Count() to check for the presence of items in a sequence! You should generally use Any(), as Count() needs to read the complete sequence. (In your example prefer !posts.Any() over posts.Count() == 0; because you are materializing the sequence twice, in Count() and on iterating the sequence.)

    Comments closed

    Comments have been closed since this content was published more than 30 days ago, but if you'd like to send us feedback you can Contact Us.