jibcage
jibcage

Reputation: 51

How to convert Atom to RSS?

I've been searching around for a way to convert an Atom feed to an RSS feed. I tried atom2rss but it only gave me the first paragraph or so of the document, then truncated it. Is there any way I could get a perl script to use the Atom and RSS libraries to convert between the two?

Upvotes: 4

Views: 2097

Answers (1)

daxim
daxim

Reputation: 39158

Obligatory "why would anyone want to do that": Atom is a real Internet standard, with a published IETF RFC, the same sort of documents that regulate the rest of the Internet. RSS is an incompatible mess.

Atom is sanely extensible, and indeed it does have fine extensions like AtomPub and threading. The times of RSS-only feed readers is long over, so dual-publishing is not necessary anymore, just publish Atom feeds and you're set.

But if you do not care about that and have a job to finish, XML::Feed offers conversion as part of its API (code untested), thoroughly validate what you are going to get as output:

my $atom = XML::Feed->parse(URI->new('http://example.com/atom.xml'));
my $rss = $atom->convert('RSS');
print $rss->as_xml;

Upvotes: 5

Related Questions