2010-07-31 7 views
1

이 ATOM 피드 (http://ffffound.com/feed)를 읽으려고하고 있지만 네임 스페이스의 일부로 정의 된 값을 얻을 수 없습니다. 미디어 : 콘텐츠 및 미디어 : 미리보기 이미지.사용자 정의 네임 스페이스를 사용하는 Ruby의 ATOM 구문 분석

파서가 네임 스페이스를 인식하도록해야합니까?

는 여기에 내가 '적이 무엇을 가지고 :

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

난 당신이 그것에 대해 libxml - 루비를 사용해야합니다 생각합니다.

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 

올바른 방향으로 안내해 주시기 바랍니다.

관련 문제