Click here to Skip to main content
13,200,202 members (56,405 online)
Click here to Skip to main content
Add your own
alternative version


25 bookmarked
Posted 31 Jan 2011


Rate this:
Please Sign up or sign in to vote.
Language Integrated Query in RSS


RSS stands for Really Simple Syndication. RSS is a sort of web feed which allows us to publish any kind of frequent data such as news, blogs, ... etc.
LINQ is a cool technology for querying because it's data source independent, so from that point I started developing LINQ to RSS, which is a simple library that simplifies the querying with RSS documents.


RSS is an XML-based document that contains the feeds for a specific channel, it has .rss or .xml extension.

<rss version="2.0">


    <title>News Headlines</title>
    <description>News Website.</description>
    <lastBuildDate>Mon, 06 Sep 2010 00:01:00</lastBuildDate>

        some description goes here.
      <title>Space Exploration</title>
        some description goes here.

From the above file, we can notice that each RSS file contains channel tag which contains a descriptive information about the current channel that provides the feeds, underneath item tag which represents the feeds themselves. Each item contains a descriptive information about a specific item such as title, link and so forth.

There's no magic in LINQ .. just whenever you have any kind of data source XML, database, registry... etc. If you represent it into objects, it's over the LINQ which will take care about the other stuff, originally there are Lambda Expressions, Extension Methods and so forth that makes LINQ easier to query those objects.

Using the Code

Behind the scenes, the important thing in my code is the RSSDataContext class, which is a very simple class that contains a descriptive about RSS document: Channel, Feeds.

Public Class RssDataContext
    Public Sub New(ByVal Path As String)
        Dim doc As XDocument = XDocument.Load(Path)
        Feeds = From item In doc.Element("rss").Element("channel").Elements("item")
                Select New Feed With {.Title = item.Element("title").Value, _
		.Link = item.Element("link").Value, _
		.Description = item.Element("description").Value, _
		.PublicationDate = item.Element("pubDate").Value, _
		.GUID = Guid.Parse(item.Element("guid").Value)}

        Channel = New Channel() With {.Title = doc...<title>.Value, _
		.Link = doc...<link>.Value, _
		.Description = doc...<description>.Value, _
		.PublicationDate = doc...<pubDate>.Value, _
		.LastBuildDate = doc...<lastBuildDate>.Value}
    End Sub

    Public Property Feeds As IEnumerable(Of Feed)

    Public Property Channel As Channel
End Class		

Feed class is nothing but a piece pf code that represents each feed in the RSS document:

Public Class Feed
    Property Title As String
    Property Link As String
    Property Description As String
    Property PublicationDate As DateTime
    Property GUID As Guid
End Class

as well as channel class:

Public Class Channel
    Property Title As String
    Property Link As String
    Property Description As String
    Property PublicationDate As DateTime
    Property LastBuildDate As DateTime
End Class

Now we can use it like this:

Dim db As New RssDataContext("rss.xml")
        Dim feeds = From f In db.Feeds
                    Select f

        For Each f As Feed In feeds

I think it's cool that whenever someone wants to query RSS document with strong type instead of dealing with XML, there's no need to spend a lot of time learning XML programming when you want any information from RSS. Just try my code and I hope you enjoy it.

Points of Interest

  • Developing RSS Aggregator (Reader)
  • Display a bunch of the web feeds inside your web application (RSS Feed Module)


  • LinqToRss version 1.0 which contains the basic functionality to query and RSS document


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

You may also be interested in...

Comments and Discussions

AnswerLINQ to RSS Pin
Hisham Abdullah Bin Ateya1-Feb-11 20:38
memberHisham Abdullah Bin Ateya1-Feb-11 20:38 
Thank you Pranay Rana. I hope you enjoyed with my idea, If you have any feedback I 'll be thankful for you!!
As soon as possible I'm gonna release a new stuff with LINQ!!
GeneralRe: LINQ to RSS Pin
mossandlichens17-Apr-11 23:08
membermossandlichens17-Apr-11 23:08 
Generalnice one Pin
Pranay Rana1-Feb-11 6:22
memberPranay Rana1-Feb-11 6:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.171020.1 | Last Updated 2 Feb 2011
Article Copyright 2011 by Hisham Abdullah Bin Ateya
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid