Perl Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

Perl Examples

Quick Start
Unicode
Byte Array
Bz2
Certificates
CSV
Email
Encryption
FTP
HTML-to-XML
HTTP
IMAP
MHT
MIME
POP3
RSA
S/MIME
Signatures
SMTP
Socket / SSL
Spider
SFTP
SSH Key
SSH
SSH Tunnel
Tar
HTTP Upload
XML
XMP
Zip

More Examples...
String
Email Object
FileAccess
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA

Unreleased...
Bzip2
LZW
Icon

 

 

 

 

 

 

 

Read RSS Feed

Sample code showing how to read an RSS feed and display the contents.

The Chilkat RSS class/component is freeware.

Download Chilkat Perl Module

use chilkat;

$rss = new chilkat::CkRss();

#  Download from the feed URL:
$success = $rss->DownloadRss("http://blog.chilkatsoft.com/?feed=rss2");
if ($success != 1) {
    print $rss->lastErrorText() . "\n";
    exit;
}

#  Get the 1st channel.

$rssChannel = $rss->GetChannel(0);
if ($rssChannel eq null ) {
    print "No channel found in RSS feed." . "\n";
    exit;
}

#  Display the various pieces of information about the channel:
print "Title: " . $rssChannel->getString("title") . "\r\n";
print "Link: " . $rssChannel->getString("link") . "\r\n";
print "Description: " . $rssChannel->getString("description") . "\r\n";

#  For each item in the channel, display the title, link,
#  publish date, and categories assigned to the post.
$numItems = $rssChannel->get_NumItems();

for ($i = 0; $i <= $numItems - 1; $i++) {
    $rssItem = $rssChannel->GetItem($i);

    print "----" . "\r\n";
    print "Title: " . $rssItem->getString("title") . "\r\n";
    print "Link: " . $rssItem->getString("link") . "\r\n";
    print "pubDate: " . $rssItem->getString("pubDate") . "\r\n";

    $numCategories = $rssItem->GetCount("category");

    if ($numCategories > 0) {
        for ($j = 0; $j <= $numCategories - 1; $j++) {
            print "    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.