Reading non-standard/custom attributes in Atom feeds with standardRuby RSS Library - How?

G

Gerald Bauer

Hello,

Using the latest version of the standard web feed library
(RSS::parser) [1], that is, 0.2.4, I tried to configure or extend it
so I can read/access non-standard (custom) feed attributes such as the
Google Readers' original-id. Example:

<id gr:eek:riginal-id="http://rubybook.wordpress.com/p=20">tag:google.com,2005:reader/item/7931b28aaa03e64c</id>

If anyone has tried something similar or has any tips or tricks on
how to go about I greatly appreciate it. Cheers.


[1] http://raa.ruby-lang.org/project/rss
 
G

Gerald Bauer

Hello,
Using the latest version of the standard web feed library
(RSS::parser) [1], that is, 0.2.4, I tried to configure or extend it
so I can read/access non-standard (custom) feed attributes such as the
Google Readers' original-id. Example:

<id gr:eek:riginal-id="http://rubybook.wordpress.com/p=20">tag:google.com,2005:reader/item/7931b28aaa03e64c</id>

If anyone has tried something similar or has any tips or tricks on
how to go about I greatly appreciate it.

I've got it working. [1] It looks like the standard RSS::parser
library cannot handle XML attributes with a dash (such as original-id)
because it generates Ruby attributes using the XML attribute's name,
thus, leading to invalid Ruby identifiers. Using a .gsub(
'gr:eek:riginal-id', 'gr:eek:riginal_id' ) on the feed data works around it
although ideally I rather prefer not to.

Any comments, fixes or alternative workarounds welcome. Cheers.


[1]:
module RSS
module Atom

class Feed
class Entry

class Id < RSS::Element

install_get_attribute( 'original_id', "", false )

end

end
end
end
end
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top