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

Discussion in 'Ruby' started by Gerald Bauer, Jul 21, 2008.

  1. Gerald Bauer

    Gerald Bauer Guest

    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

    --
    Gerald Bauer - Internet Professional - http://geraldbauer.wordpress.com
     
    Gerald Bauer, Jul 21, 2008
    #1
    1. Advertising

  2. Gerald Bauer

    Gerald Bauer Guest

    Re: Reading non-standard/custom attributes in Atom feeds withstandard Ruby RSS Library - How?

    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
     
    Gerald Bauer, Jul 21, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sachin Garg
    Replies:
    0
    Views:
    576
    Sachin Garg
    Jul 18, 2005
  2. rdaly
    Replies:
    0
    Views:
    380
    rdaly
    May 15, 2007
  3. rdaly
    Replies:
    5
    Views:
    496
    rdaly
    May 15, 2007
  4. Gerald Bauer
    Replies:
    0
    Views:
    222
    Gerald Bauer
    Jul 15, 2008
  5. Richard Conroy
    Replies:
    4
    Views:
    153
    Walton Hoops
    Jun 23, 2010
Loading...

Share This Page