How To Create An RSS Reader In VB.NET

Last post 01-06-2009 2:38 PM by gurren. 7 replies.

Sort Posts:

  • How To Create An RSS Reader In VB.NET

    09-19-2007, 3:05 PM
    • Participant
      751 point Participant
    • KJAK
    • Member since 03-14-2006, 4:07 PM
    • Posts 250

     Well... The topic is pretty much the question. I would like to know how to create a custom RSS Reader for my web pages. I have been looking online, but haven't found anything that uses VB.NET.

     As a side note to the web reader: I would also like to know how to create a gadget reader for Windows Vista Sidebar - if anyone can help me with that as well.

    Thanks,
    KJAK
     

    Respect to the community...

    KJAK
    Filed under:
  • Re: How To Create An RSS Reader In VB.NET

    09-19-2007, 3:16 PM
    Answer

     Public Shared Function ProcessRSS(ByVal rssURL As String, ByVal feed As String) As String
        Dim request As WebRequest = WebRequest.Create(rssURL)
        Dim response As WebResponse = request.GetResponse()
        Dim sb As New StringBuilder("")
        Dim rssStream As Stream = response.GetResponseStream()
        Dim rssDoc As New XmlDocument()
        rssDoc.Load(rssStream)
        Dim rssItems As XmlNodeList = rssDoc.SelectNodes("rss/channel/item")

        Dim title As String = ""
        Dim link As String = ""
        Dim upperlimit As Integer = rssItems.Count
        If upperlimit > 5 Then
            upperlimit = 5
        End If
        If upperlimit > 0 Then
            sb.Append("<p>" + feed + "</p><ul>")
            Dim i As Integer = 0
            While i < upperlimit
                Dim rssDetail As XmlNode
                rssDetail = rssItems.Item(i).SelectSingleNode("title")
                If rssDetail <> Nothing Then
                    title = rssDetail.InnerText
                Else
                    title = ""
                End If

                rssDetail = rssItems.Item(i).SelectSingleNode("link")
                If rssDetail <> Nothing Then
                    link = rssDetail.InnerText
                Else
                    link = ""
                End If
                sb.Append("<li><a href='" + link + "' target='_blank'>" + title + "</a></li>")
                i+=1
            End While
            sb.Append("</ul>")
        End If
        Return sb.ToString()
    End Function

    Then to call the method:

    Feed1.Text = ProcessRSS("http://weblogs.asp.net/scottgu/rss.aspx", "ScottGu")

    Where Feed1 is an asp:Literal control.

    All I did was take the C# code from this article, and shove it into www.codechanger.com 

     

    Regards Mike
    [MVP - ASP/ASP.NET]
    My site
  • Re: How To Create An RSS Reader In VB.NET

    09-19-2007, 3:20 PM
    Answer
    • All-Star
      45,563 point All-Star
    • haidar_bilal
    • Member since 07-14-2003, 1:43 AM
    • Lebanon - Beirut
    • Posts 8,726
    • TrustedFriends-MVPs
    You could have a look at this article: http://aspnet.4guysfromrolla.com/articles/102903-1.aspx Also, there is an ASP.NET RSS Toolkit by Dmitry Robinson, check it here: http://www.codeplex.com/ASPNETRSSToolkit Hope this helps, Regards
    Bilal Hadiar, MCP, MCTS, MCPD, MCT
    Microsoft MVP - Telerik MVP
  • Re: How To Create An RSS Reader In VB.NET

    09-19-2007, 3:34 PM
    Answer
    • Contributor
      3,793 point Contributor
    • jguadagno
    • Member since 03-17-2003, 7:02 AM
    • Chandler, AZ
    • Posts 587

     I would look at the ASP.NET RSS Toolkit .  It has a RSSDataSource which you can use to bind to RSS feeds.

    Joseph Guadagno
    My Website: http://www.josephguadagno.net
    My Blog - http://weblogs.asp.net/jguadagno/

    If this has helped Please: Don't forget to click "Mark as Answer" on the post that helped you.
    That way future readers will know which post solved your issue.
  • Re: How To Create An RSS Reader In VB.NET

    09-20-2007, 8:58 AM
    • Participant
      751 point Participant
    • KJAK
    • Member since 03-14-2006, 4:07 PM
    • Posts 250

     Thanks for all of the responses. Each one helps for different situations so I have marked all as answers. I even found really good article on msdn that explains how to make a Windows Sidebar gadget: http://msdn.microsoft.com/msdnmag/issues/07/08/SideBar/

    Thanks again!
    KJAK

    Respect to the community...

    KJAK
  • Re: How To Create An RSS Reader In VB.NET

    03-28-2008, 2:55 PM
    • Member
      482 point Member
    • grbourque
    • Member since 06-14-2007, 11:34 PM
    • Posts 120

    I know this is an old thread and I just used Mikesdotnetting solution on my site. 

    Found one thing that needs to be changed though for VB.net

    If rssDetail <> Nothing Then

    This needs to be changed to

    If NOT rssDetail IS Nothing Then 

    Works like a champ.  Thanks.

  • Re: How To Create An RSS Reader In VB.NET

    03-28-2008, 5:56 PM

    grbourque:
    Found one thing that needs to be changed though for VB.net
     

    Nice spot.  Codechanger.com is normally very good.  But there are one or two anomolies I noticed.

     

    Regards Mike
    [MVP - ASP/ASP.NET]
    My site
  • Re: How To Create An RSS Reader In VB.NET

    01-06-2009, 2:38 PM
    • Member
      15 point Member
    • gurren
    • Member since 01-06-2009, 2:35 PM
    • Posts 5

     This works great, but I run into a problem when the rssItems.Count is less than what I manually set as the upperlimit.  It will truncate the last entry and cause page formatting issues.

     Has anyone else experienced an issue similar to this?

Page 1 of 1 (8 items)