Data::Feed - Extensible Feed Parsing Tool


  use Data::Feed;

  # from a file
  $feed = Data::Feed->parse( '/path/to/my/feed.xml' );

  # from an URI
  $feed = Data::Feed->parse( URI->new( '' ) );

  # from a string
  $feed = Data::Feed->parse( \$feed );

  # from a handle
  $feed = Data::Feed->parse( $fh );

  # Data::Feed auto-guesses the type of a feed by its contents, but you can
  # explicitly tell what parser to use

  $feed = Data::Feed->new( parser => $myparser )->parse(...);


Data::Feed is a frontend for feeds. It will attempt to auto-guess what type of feed you are passing it, and will generate the appropriate feed object.

What, another XML::Feed? Yes, but this time it's extensible. It's cleanly OO (until you get down to the XML nastiness), and it's easy to add your own parser to do whatever you want it to do.


Data::Feed has a fairly simple structure. The first layer is a "dynamic" parser -- "dynamic" in that Data::Feed will try to find what the feed is, and then create the appropriate parser to parse it.

This is done in Data::Feed->find_parser() and Data::Feed->guess_format(). By default we recognize RSS and Atom feeds. Should the need arise to either provide a custom parser or to provide more refined logic to find a parser type, override the respective method and do what you will with it.

The second layer is a thin wrapper around RSS and Atom feed objects. We use XML::RSS::LibXML (or XML::RSS) and XML::Atom for this purpose.


Data::Feed can parse files, URIs, raw strings, and file handles. All you need to do is to pass an appropriate parameters.

For file names, we expect a plain scalar:

  Data::Feed->parse( '/path/to/feed.xml' );

For URI, pass in an URI object:

  Data::Feed->parse( URI->new("") );

For raw strings, pass in a scalar ref:

  Data::Feed->parse( \qq{<?xml version="1.0"><feed> .... </feed>} );

For file handles, pass in a glob:

  open(my $fh, '<', '/path/to/feed.xml' );
  Data::Feed->parse( $fh );




Attempts to find an appropriate parser for the given stream.




Parses a datetime string, first trying DateTime::Format::ISO8601, then DateTime::Format::Flexible, and finally DateTime::Format::Natural. The first one to succeed will have its value returned. If none succeeds, it returns undef. Used by the format classes to create the values returned by the issued() and modified() methods.


Like parse_datetime(), but tries parsing the string with DateTime::Format::W3CDTF before falling back on parse_datetime().


Like parse_datetime(), but tries parsing the string with DateTime::Format::Mail before falling back on parse_datetime().


Be able to /set/ enclosures (We can already get enclosures).


Daisuke Maki <>

Taro Funaki <>

A /Lot/ of the code is based on code from XML::Feed.


This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.