I Like Monkey Ruby

Ruby code posted by Kevin Baker
created at 17 Feb 09:59, updated at 17 Feb 16:09

Edit | Back
1
2
3
4
5
6
7
8
9
10
11
12
13
14
  def parseFeed (url, length)
    feed_url = url
    output = "";
    open(feed_url) do |http|
      response = http.read
      result = RSS::Parser.parse(response, false)
      output = "<span class=\"feedTitle\">#{result.channel.title}</span><br /><ul>"
      result.items.each_with_index do |item, i|
        output += "<li><a href=\"#{item.link}\">#{item.title}</a></li>" if ++i < length
      end
      output += "</ul>"
    end
    return output
  end
470 Bytes in 2 ms with coderay