RssItemNodes = ( "channel/item")įor index in 0.rssItemNodes.length - 1 do # Create New RSSItem RssChannel.RssItems = loadRssItemsFromUrl(rssUrl)Įnd def loadRssItemsFromUrl (rssUrl) # Read RSS from url (using nokogiri library) RssChannel.PubDate = rssChannelNode.at_xpath( "pubDate").content RssChannel.Link = rssChannelNode.at_xpath( "link").content RssChannel.Description = rssChannelNode.at_xpath( "description").content RssChannel.Title = _xpath( "channel/title").content Require_relative 'rssData.rb' class RssManager def loadRssChannelFromUrl (rssUrl) # Read rss from url (using nokogiri library) The rssManager.rb also implements the rssData.rb we have created earlier to manage and store data from our RSS Feed require 'open-uri' require 'nokogiri' The nokogiri library is used for parsing XML Files. The open-uri library is used for HTTP, HTTPS or FTP connections and allows the user to open a URL as though it were a file. The rssManager.rb makes use of 2 libraries that are called open-uri and nokogiri. The rssManager.rb file is our custom Library/API to extract and parse data from online RSS Feeds. class RssChannel def Title= tĮnd def end class RssItem def Title= t We will need to create 2 Data Models, the RssChannel Model to store information about the RSS Feed, and the RssItem Model to store the data from the items inside an RssChannel. The rssData.rb file contain the data models we will be using to manage and store RSS Data from an online RSS Feed. Step 2 : Open a texteditor and create the following files with the. Step 1 : Create a new folder on your local drive called RssReaderApp An example feed could have contents such as the following: The RSS format itself is relatively easy to read both by automated processes and by humans alike. The program downloads and displays the Rss Feed of Yahoo News! RSS Stands for Really Simple Syndication and is a type of web feed which allows users and applications to access data on websites in a standardized, computer-readable format. The following code example is a Ruby version of the Rss Reader Application. An installer dialog will appear on your screen.Ĭreating an RSS Reader Application for Ruby
0 Comments
Leave a Reply. |