Function ProcessRSSItem() As String Dim rssURL As String = "http://www.abc.com/rss.rss" Dim myRequest As WebRequest = System.Net.WebRequest.Create(rssURL) Dim myResponse As WebResponse = myRequest.GetResponse() Dim rssStream As Stream = myResponse.GetResponseStream() Dim rssDoc As New XmlDocument() rssDoc.Load(rssStream) Dim nsmg As New XmlNamespaceManager(rssDoc.NameTable) nsmg.AddNamespace("dc", "http://purl.org/dc/elements/1.1/") Dim rssItems As XmlNodeList = rssDoc.SelectNodes("rss/channel/item") Dim title As String = "" Dim link As String = "" Dim description As String = "" Dim i As Integer = 0 Dim numItems As Integer = 1 Dim sb As New System.Text.StringBuilder Dim rssDetail As XmlNode Do Until numItems = 10 rssDetail = rssItems.Item(i).SelectSingleNode("dc:language", nsmg) Console.WriteLine(rssDetail.InnerText.ToString()) If rssDetail.InnerText.Equals("en-US") Then rssDetail = rssItems.Item(i).SelectSingleNode("title") If rssDetail.Equals(Nothing) = False Then title = rssDetail.InnerText Else title = "" End If rssDetail = rssItems.Item(i).SelectSingleNode("link") If rssDetail.Equals(Nothing) = False Then link = rssDetail.InnerText Else link = "" End If rssDetail = rssItems.Item(i).SelectSingleNode("description") If rssDetail.Equals(Nothing) = False Then description = rssDetail.InnerText Else description = "" End If sb.Append("" + title + "
") numItems = i + 1 End If i = i + 1 Loop Return sb.ToString End Function
") sb.Append(description + "
Friday, July 22, 2011
Retrieve RSS feeds and display in ASP.Net VB
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment