XML : Putting RSS titles in an array and checking if they are in another array

I'm trying to compare two different RSS feeds, let's say Site A to Site B. Both Site A and Site B have ten items in their RSS feed. I want to grab the two most recent RSS items in Site A, and see if they are present in any of the ten items of Site B.

I've gotten far enough to parse the RSS feed for Site A, and I let it grab only the top two. This is what I have so far:

  require 'open-uri'  require 'rss'      url = 'http://www.ruby-lang.org/en/feeds/news.rss'    open(url) do |rss|      feed = RSS::Parser.parse(rss)      puts "Title: #{feed.channel.title}"      feed.items.take(2).each do |item|          puts "Item: #{item.title}"      end  end    

I'm not sure how I can put it into an array from there and compare it against the parsing for Site B. I would really appreciate a bump in the right direction. Should I use each_with_index?

No comments:

Post a Comment