ruby-on-railsrubyparsingrssfeedzirra

Parsing custom feed elements using FeedZirra


Is there a way to parse feed's custom elements? Not feed entries', feed's custom elements. I know there is a way to do the same for the entries. Like,

Feedzirra::Feed.add_common_feed_entry_element("wfw:commentRss", :as => :comment_rss)
feed = Feedzirra::Feed.parse(some_atom_xml)
feed.entries.first.comment_rss # => wfw:commentRss is now parsed!

I want to be able to achieve the same for the feed object. Something like,

Feedzirra::Feed.add_common_feed_element("geo:lat", :as => :latitudes)
feed = Feedzirra::Feed.fetch_and_parse(“somerss”)
feed.latitudes # => 44.022448

Is there a way? Or does this requires writing a patch for FeedZirra?


Solution

  • It's a bit late, but more people might be looking for an answer. Putting the following line in a file in your config/initializers seems to work:

    Feedzirra::Parser::RSS.element :latitudes