mldvx4 has asked for the wisdom of the Perl Monks concerning the following question:

There are several choices for modules which claim to generate RSS feeds. Are there any tips as to which one to focus on?

  • Comment on Recommendations for generating RSS feed?

Replies are listed 'Best First'.
Re: Recommendations for generating RSS feed?
by tobyink (Canon) on Jun 07, 2018 at 20:26 UTC

    I've used XML::RSS with some success in the past. I know that it's still actively maintained. That would be the third one on your list.

Re: Recommendations for generating RSS feed?
by ikegami (Patriarch) on Jun 08, 2018 at 00:50 UTC

    RSS is a bit of a mess —there are three versions, each fixing design flaws in the previous— so when I needed to generate a feed, I made it an atom feed.

    I used XML::Atom::Syndication with these helpers:

    sub new_atom_obj { my $class = 'XML::Atom::Syndication::' . shift; ( my $file = $class ) =~ s{::}{/}g; $file .= '.pm'; require($file); unshift @_, $class; goto &{ $class->can('new') }; } sub set_fields { my $self = shift; while (@_) { my $field = shift; my $val = shift; $self->$field($self, $val); } return $self; }

    The code looked like this:

    my $atom_dt_format = DateTime::Format::Atom->new(); my $feed_title = ...; my $feed_content_url = ...; my $feed = set_fields( new_atom_obj('Feed'), title => set_fields( new_atom_obj('Text', Name => 'title'), type => + 'text', body => $feed_title ), link => set_fields( new_atom_obj('Link'), href => $feed_content_ur +l ), ); while (...) { my $entry_title = ...; my $entry_content_url = ...; my $entry_pub_dt = ...; my $entry_body = ...; $feed->add_entry( set_fields( new_atom_obj('Entry'), title => set_fields( new_atom_obj('Text', Name => 'title' +), type => 'text', body => $entry_title ), link => set_fields( new_atom_obj('Link', Name => 'link') +, href => $entry_content_url ), published => $atom_dt_format->format_datetime($entry_pub_dt), content => set_fields( new_atom_obj('Content'), type => 'ht +ml', body => $entry_body), ), ); } $feed->updated($atom_dt_format->format_datetime($feed_last_updated)); return $feed->as_xml();