Created
October 15, 2009 10:54
-
-
Save ocean/210889 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>Feeds Checker</h1> | |
<% | |
require 'hpricot' | |
require 'open-uri' | |
f1 = open("http://www.commerce.wa.gov.au/feeds/feed1.xml") | |
feed = Hpricot.XML(f1) | |
#thing = (feed/:channel/:title).inner_html # works but returns *all* "title" tags, not just channel one. | |
feedTitle = feed.search("/rss/channel/title").innerHTML | |
feedItem = feed.search("rss/channel//item") | |
%> | |
<p>Here is some content I prepared earlier.</p> | |
<h3><%= feedTitle %></h3> <!-- This bit works! --> | |
<% | |
feedItem.each do |el| | |
title = el.search("title").first.inner_html | |
#url = el.search("link").first.inner_html | |
url = el.get_elements_by_tag_name("link").inner_html | |
desc = el.search("description").first.inner_html | |
output = "<p><a href='#{url}'>#{title}</a></p>" | |
puts output # This bit doesn't :-(((( | |
end | |
%> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment