Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Delphi DLL) Read RSS FeedSample code showing how to read an RSS feed and emit the contents.
uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Rss; ... procedure TForm1.Button1Click(Sender: TObject); var rss: HCkRss; success: Boolean; rssChannel: HCkRss; numItems: Integer; i: Integer; rssItem: HCkRss; numCategories: Integer; j: Integer; begin rss := CkRss_Create(); // Download from the feed URL: success := CkRss_DownloadRss(rss,'http://www.nytimes.com/services/xml/rss/nyt/HomePage.xml'); if (success <> True) then begin Memo1.Lines.Add(CkRss__lastErrorText(rss)); Exit; end; // Get the 1st channel. rssChannel := CkRss_GetChannel(rss,0); if (CkRss_getLastMethodSuccess(rss) = False) then begin Memo1.Lines.Add('No channel found in RSS feed.'); Exit; end; // Display the various pieces of information about the channel: Memo1.Lines.Add('Title: ' + CkRss__getString(rssChannel,'title')); Memo1.Lines.Add('Link: ' + CkRss__getString(rssChannel,'link')); Memo1.Lines.Add('Description: ' + CkRss__getString(rssChannel,'description')); // For each item in the channel, display the title, link, // publish date, and categories assigned to the post. numItems := CkRss_getNumItems(rssChannel); for i := 0 to numItems - 1 do begin rssItem := CkRss_GetItem(rssChannel,i); Memo1.Lines.Add('----'); Memo1.Lines.Add('Title: ' + CkRss__getString(rssItem,'title')); Memo1.Lines.Add('Link: ' + CkRss__getString(rssItem,'link')); Memo1.Lines.Add('pubDate: ' + CkRss__getString(rssItem,'pubDate')); numCategories := CkRss_GetCount(rssItem,'category'); if (numCategories > 0) then begin for j := 0 to numCategories - 1 do begin Memo1.Lines.Add(' category: ' + CkRss__mGetString(rssItem,'category',j)); end; end; CkRss_Dispose(rssItem); end; CkRss_Dispose(rssChannel); CkRss_Dispose(rss); end; |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.