Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Java) Read RSS FeedSample code showing how to read an RSS feed and emit the contents.
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(); // Download from the feed URL: boolean success = rss.DownloadRss("http://www.nytimes.com/services/xml/rss/nyt/HomePage.xml"); if (success != true) { System.out.println(rss.lastErrorText()); return; } // Get the 1st channel. CkRss rssChannel = rss.GetChannel(0); if (rss.get_LastMethodSuccess() == false) { 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 = rssChannel.get_NumItems(); int i; for (i = 0; i <= numItems - 1; i++) { CkRss 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 = rssItem.GetCount("category"); int j; if (numCategories > 0) { for (j = 0; j <= numCategories - 1; j++) { System.out.println(" category: " + rssItem.mGetString("category",j)); } } } } } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.