Java Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

Java Examples

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

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

Unreleased...
Bzip2
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 Java Library

import com.chilkatsoft.*;

public class ChilkatExample {

  static {
    try {
        System.loadLibrary("chilkat");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load.\n" + e);
      System.exit(1);
    }
  }

  public static void main(String argv[])
  {
    CkRss rss = new CkRss();

    boolean success;

    //  Download from the feed URL:
    success = rss.DownloadRss("http://blog.chilkatsoft.com/?feed=rss2");
    if (success != true) {
        System.out.println(rss.lastErrorText());
        return;
    }

    //  Get the 1st channel.
    CkRss rssChannel;

    rssChannel = rss.GetChannel(0);
    if (rssChannel == null ) {
        System.out.println("No channel found in RSS feed.");
        return;
    }

    //  Display the various pieces of information about the channel:
    System.out.println("Title: " + rssChannel.getString("title"));
    System.out.println("Link: " + rssChannel.getString("link"));
    System.out.println("Description: " + rssChannel.getString("description"));

    //  For each item in the channel, display the title, link,
    //  publish date, and categories assigned to the post.
    int numItems;
    numItems = rssChannel.get_NumItems();
    int i;

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

        System.out.println("----");
        System.out.println("Title: " + rssItem.getString("title"));
        System.out.println("Link: " + rssItem.getString("link"));
        System.out.println("pubDate: " + rssItem.getString("pubDate"));

        int numCategories;
        numCategories = rssItem.GetCount("category");
        int j;
        if (numCategories > 0) {
            for (j = 0; j <= numCategories - 1; j++) {
                System.out.println("    category: "
                     + rssItem.mGetString("category",j));
            }

        }

    }


  }
}

 

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

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