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
(Swift 3,4,5...) Read RSS FeedSample code showing how to read an RSS feed and emit the contents.
func chilkatTest() { let rss = CkoRss()! // Download from the feed URL: var success: Bool = rss.downloadRss("http://www.nytimes.com/services/xml/rss/nyt/HomePage.xml") if success != true { print("\(rss.lastErrorText!)") return } // Get the 1st channel. var rssChannel: CkoRss? = rss.getChannel(0) if rss.lastMethodSuccess == false { print("No channel found in RSS feed.") return } // Display the various pieces of information about the channel: print("Title: \(rssChannel!.getString("title")!)") print("Link: \(rssChannel!.getString("link")!)") print("Description: \(rssChannel!.getString("description")!)") // For each item in the channel, display the title, link, // publish date, and categories assigned to the post. var numItems: Int = rssChannel!.numItems.intValue var i: Int for i = 0; i <= numItems - 1; i++ { var rssItem: CkoRss? = rssChannel!.getItem(i) print("----") print("Title: \(rssItem!.getString("title")!)") print("Link: \(rssItem!.getString("link")!)") print("pubDate: \(rssItem!.getString("pubDate")!)") var numCategories: Int = rssItem!.getCount("category").intValue var j: Int if numCategories > 0 { for j = 0; j <= numCategories - 1; j++ { print(" category: \(rssItem!.mGet("category", index: j)!)") } } rssItem = nil } rssChannel = nil } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.