RSS Feeds in a vb.net desktop application…
Ok so i thought it would be a good idea to write an RSS feed reading into the project that im currently working on.
Based on this i found the following code:
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("" + feed + "- “)
Dim i As Integer = 0
While i < upperlimit
Dim rssDetail As XmlNode
rssDetail = rssItems.Item(i).SelectSingleNode(”title”)
If Not IsNothing(rssDetail) Then
title = rssDetail.InnerText
Else
title = “”
End If
rssDetail = rssItems.Item(i).SelectSingleNode(”link”)
If Not IsNothing(rssDetail) Then
link = rssDetail.InnerText
Else
link = “”
End If
sb.Append(”
“)
i += 1
End While
sb.Append(”")
End If
Return sb.ToString()
this is all good and seams to work.. except i needed to add a proxy logon:
request.Proxy.Credentials = CredentialCache.DefaultCredentials