Search code examples
xmlperlrsscpanatom-feed

What's the best library for parsing RSS/Atom in Perl?


I notice that XML::RSS::Parser hasn't been updated since 2005. Is this still the recommended library for parsing RSS or Atom? Is there a better one or a better way?


Solution

  • I'm not sure it's ever been the "recommended library". If I know which kind of feed I need to parse, I use XML::RSS or XML::Atom as appropriate, but if (as is more likely) I just know it's a web feed, I use XML::Feed.

    Adding an example of using XML::Feed as requested..

    use XML::Feed;
    
    my $feed = XML::Feed->parse(\$string_containing_feed);
    
    foreach ($feed->entries) {
      print $_->title, "\n";
      print $_->content->body, "\n";
    }
    

    This is all pretty much copied from the module documentation.