RSS parsing

7 views
Skip to first unread message

dtolj

unread,
Feb 8, 2011, 8:17:14 PM2/8/11
to hpricot
I am trying to use Hpricot XML feature to parse an RSS feed.

I would like to modify an existing RSS and insert a new element called
"<media:thumb url=... />" inside every item. The item contains other
elements as well.
There is an insert_after method but it seems to be adding the element
at the end of the document.

require 'rubygems'
require 'hpricot'
require 'open-uri'

fh=open('http://path_to_rss')
doc=Hpricot::XML(fh)
doc.insert_after(Hpricot::XML("<media:thumb url='...' />"),
doc.at("item") )
Reply all
Reply to author
Forward
0 new messages