Parsing custom feed elements with FeedZirra

Is there a way to parse a feed of custom elements? Do not upload entries, "upload custom elements. I know there is a way to do the same for entries. How,

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. Sort of,

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

Is there any way? Or does it require writing a patch for FeedZirra?

+4
source share
2 answers

A little late, but more people can find the answer. The following line seems to work in the file in your config / initializers:

 Feedzirra::Parser::RSS.element :latitudes 
+4
source

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 
0
source

Source: https://habr.com/ru/post/1316651/


All Articles