Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Read RSS Feed
Sample code showing how to read an RSS feed and display the contents. The Chilkat RSS class/component is freeware. Dim rss As New Chilkat.Rss() Dim success As Boolean ' Download from the feed URL: success = rss.DownloadRss("http://blog.chilkatsoft.com/?feed=rss2") If (success <> true) Then MsgBox(rss.LastErrorText) Exit Sub End If ' Get the 1st channel. Dim rssChannel As Chilkat.Rss rssChannel = rss.GetChannel(0) If (rssChannel Is Nothing ) Then MsgBox("No channel found in RSS feed.") Exit Sub End If ' Display the various pieces of information about the channel: TextBox1.Text = TextBox1.Text & "Title: " & rssChannel.GetString("title") & vbCrLf TextBox1.Text = TextBox1.Text & "Link: " & rssChannel.GetString("link") & vbCrLf TextBox1.Text = TextBox1.Text & "Description: " _ & rssChannel.GetString("description") & vbCrLf ' For each item in the channel, display the title, link, ' publish date, and categories assigned to the post. Dim numItems As Long numItems = rssChannel.NumItems Dim i As Long For i = 0 To numItems - 1 Dim rssItem As Chilkat.Rss rssItem = rssChannel.GetItem(i) TextBox1.Text = TextBox1.Text & "----" & vbCrLf TextBox1.Text = TextBox1.Text & "Title: " _ & rssItem.GetString("title") & vbCrLf TextBox1.Text = TextBox1.Text & "Link: " _ & rssItem.GetString("link") & vbCrLf TextBox1.Text = TextBox1.Text & "pubDate: " _ & rssItem.GetString("pubDate") & vbCrLf Dim numCategories As Long numCategories = rssItem.GetCount("category") Dim j As Long If (numCategories > 0) Then For j = 0 To numCategories - 1 TextBox1.Text = TextBox1.Text & " category: " _ & rssItem.MGetString("category",j) & vbCrLf Next End If Next |
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2007 Chilkat Software, Inc. All Rights Reserved.