Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Reading non-standard/custom attributes in Atom feeds with standard Ruby RSS Library - How?
Gerald Bauer
7/21/2008 5:47:00 AM
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:original-id="
http://rubybook.wordpress.com/p=20">tag:google.com,2005:reader/item/7931b28aaa03e64c&...
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/p...
--
Gerald Bauer - Internet Professional -
http://geraldbauer.wor...
1 Answer
Gerald Bauer
7/21/2008 3:57:00 PM
0
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:original-id="
http://rubybook.wordpress.com/p=20">tag:google.com,2005:reader/item/7931b28aaa03e64c&...
>
> 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:original-id', 'gr:original_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
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Reading non-standard/custom attributes in Atom feeds with standard Ruby RSS Library - How?
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password