ocean (owner)

Forks

Revisions

gist: 210889 Download_button fork
public
Public Clone URL: git://gist.github.com/210889.git
Embed All Files: show embed
checker.erb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<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>