Question

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?

Was it helpful?

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

OTHER TIPS

According to the new http://feedjira.com/extending.html

# Add the generator attribute to all feed types
Feedjira::Feed.add_common_feed_element('generator')
Feedjira::Feed.fetch_and_parse("http://www.pauldix.net/atom.xml").generator # => 'TypePad'

# Add some GeoRss information
Feedjira::Feed.add_common_feed_entry_element('geo:lat', :as => :lat)
Feedjira::Feed.fetch_and_parse("http://www.earthpublisher.com/georss.php").entries.each do |e|
  p "lat: #[e.lat}, long: #{e.long]"
end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top