0
我目前使用Ruby中的Hpricot解析RSS源。来自RSS的Hpricot空链接元素
除元素外,所有元素均可检索。
这是我在做什么:
的GUID的作品,而链路发生故障时,当我(“/link").inspect它说,它是一个空元素。虽然如果您查看Feed,则所有项目都会链接具有值的元素。
doc = Hpricot.parse(open("http://www.highways.gov.uk/rssfeed/rss.xml"))
(doc/:item).each do |xml_product|
puts xml_product.search("/guid").first.children.first.raw_string
puts xml_product.search("/link").first.children.first.raw_string
end
有什么想法可能是错的?
我似乎无法在源代码中看到此格式不正确的xml吗? – easyjo
我已经更新了我的答案。请看看这个。 – WarHog