Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Read RSS FeedSample code showing how to read an RSS feed and display the contents. The Chilkat RSS class/component is freeware.
Chilkat.Rss rss = new Chilkat.Rss(); bool success; // Download from the feed URL: success = rss.DownloadRss("http://blog.chilkatsoft.com/?feed=rss2"); if (success != true) { MessageBox.Show(rss.LastErrorText); return; } // Get the 1st channel. Chilkat.Rss rssChannel = null; rssChannel = rss.GetChannel(0); if (rssChannel == null ) { MessageBox.Show("No channel found in RSS feed."); return; } // Display the various pieces of information about the channel: textBox1.Text += "Title: " + rssChannel.GetString("title") + "\r\n"; textBox1.Text += "Link: " + rssChannel.GetString("link") + "\r\n"; textBox1.Text += "Description: " + rssChannel.GetString("description") + "\r\n"; // For each item in the channel, display the title, link, // publish date, and categories assigned to the post. int numItems; numItems = rssChannel.NumItems; int i; for (i = 0; i <= numItems - 1; i++) { Chilkat.Rss rssItem = null; rssItem = rssChannel.GetItem(i); textBox1.Text += "----" + "\r\n"; textBox1.Text += "Title: " + rssItem.GetString("title") + "\r\n"; textBox1.Text += "Link: " + rssItem.GetString("link") + "\r\n"; textBox1.Text += "pubDate: " + rssItem.GetString("pubDate") + "\r\n"; int numCategories; numCategories = rssItem.GetCount("category"); int j; if (numCategories > 0) { for (j = 0; j <= numCategories - 1; j++) { textBox1.Text += " category: " + rssItem.MGetString("category",j) + "\r\n"; } } } |
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2008 Chilkat Software, Inc. All Rights Reserved.