Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
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. Note: The Chilkat XML ActiveX also includes the Chilkat RSS and Atom components. uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, CHILKATXMLLib_TLB, OleCtrls; ... procedure TForm1.Button1Click(Sender: TObject); var rss: TChilkatRss; success: Integer; rssChannel: IChilkatRss; numItems: Integer; i: Integer; rssItem: IChilkatRss; numCategories: Integer; j: Integer; begin rss := TChilkatRss.Create(Self); // Download from the feed URL: success := rss.DownloadRss('http://blog.chilkatsoft.com/?feed=rss2'); if (success <> 1) then begin ShowMessage(rss.LastErrorText); end; // Get the 1st channel. rssChannel := rss.GetChannel(0); if (rssChannel = nil ) then begin ShowMessage('No channel found in RSS feed.'); end; // Display the various pieces of information about the channel: Memo1.Lines.Add('Title: ' + rssChannel.GetString('title')); Memo1.Lines.Add('Link: ' + rssChannel.GetString('link')); Memo1.Lines.Add('Description: ' + rssChannel.GetString('description')); // For each item in the channel, display the title, link, // publish date, and categories assigned to the post. numItems := rssChannel.NumItems; for i := 0 to numItems - 1 do begin rssItem := rssChannel.GetItem(i); Memo1.Lines.Add('----'); Memo1.Lines.Add('Title: ' + rssItem.GetString('title')); Memo1.Lines.Add('Link: ' + rssItem.GetString('link')); Memo1.Lines.Add('pubDate: ' + rssItem.GetString('pubDate')); numCategories := rssItem.GetCount('category'); if (numCategories > 0) then begin for j := 0 to numCategories - 1 do begin Memo1.Lines.Add(' category: ' + rssItem.MGetString('category',j)); end; end; end; end; |
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.