Ruby Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

Ruby
Examples

Quick Start
Ruby Unicode
Ruby Byte Array
Ruby Certs
Ruby Email
Ruby Encryption
Ruby FTP
HTML-to-XML
Ruby HTTP
Ruby IMAP
Ruby MHT
Ruby MIME
Ruby S/MIME
Ruby Signatures
Ruby RSA
Ruby Socket
Ruby Spider
Ruby Tar
Ruby Upload
Ruby XML
Ruby XMP
Ruby Zip

More Examples...
String
Email Object
POP3
SMTP
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
Bzip2
DH Key Exchange
DSA
SSH Key
SSH
SSH Tunnel
SFTP

Unreleased...
LZW
Bz2
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 Ruby Library

require 'chilkat'

rss = Chilkat::CkRss.new()

#  Download from the feed URL:
success = rss.DownloadRss("http://blog.chilkatsoft.com/?feed=rss2")
if (success != true)
    print rss.lastErrorText() + "\n"
    exit
end

#  Get the 1st channel.

rssChannel = rss.GetChannel(0)
if (rssChannel == nil )
    print "No channel found in RSS feed." + "\n"
    exit
end

#  Display the various pieces of information about the channel:
print "Title: " + rssChannel.getString("title") + "\n";
print "Link: " + rssChannel.getString("link") + "\n";
print "Description: " + rssChannel.getString("description") + "\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 in 0 .. numItems - 1
    rssItem = rssChannel.GetItem(i)

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

    numCategories = rssItem.GetCount("category")

    if (numCategories > 0)
        for j in 0 .. numCategories - 1
            print "    category: " + rssItem.mGetString("category",j) + "\n";
        end

    end

end


 

Need a specific example? Send a request to support@chilkatsoft.com

© 2000-2008 Chilkat Software, Inc. All Rights Reserved.