views:

32

answers:

1

Hi,

I'm trying to read this ATOM Feed (http://ffffound.com/feed), but I'm unable to get to any of the values which are defined as part of the namespace e.g. media:content and media:thumbnail.

Do I need to make the parser aware of the namespaces?

Here's what I 've got:

require 'rss/2.0'
require 'open-uri'

source = "http://ffffound.com/feed"
content = "" 
open(source) do |s| content = s.read end
rss = RSS::Parser.parse(content, false)
+1  A: 

i believe u would have to use libxml-ruby for that

gem 'libxml-ruby', '>= 0.8.3'
require 'xml'

xml = open("http://ffffound.com/feed")
parser = XML::Parser.string(xml, :options =>XML::Parser::Options::RECOVER)
doc = parser.parse
doc.find("channel").first.find("items").each do |item|
  puts item.find("media:content").first
  #and just guessing you want that url thingy
  puts item.find("media:content").first.attributes.get_attribute("url").value
end

i hope that points u in the right direction ;)

elmac