<<

NAME

Feed::Parser - Perl extension to reliably parse RSS and Atom feeds

SYNOPSIS

  use Feed::Parser;

  my $feed = Feed::Parser->parse( $string );

  my $parser = Feed::Parser->new;  # OR
  my $parser = Feed::Parser->new( \@my_module_list );

  my $feed1 = $parser->parse( $string1 );
  my $feed2 = $parser->parse( $string2 );

DESCRIPTION

This is designed to be universal feed parser much like the Python one here: http://feedparser.org/

It differs from other feed parsers on the CPAN by being very robust and error tolerant. It also supports a wider variety of extensions then the other parsers.

PUBLIC METHODS

->new

Constructs a new Feed::Parser object that can be used to parse multiple feed documents. Constructing a new Feed::Parser object is relatively slow, so if you're parsing more then one document you should do this.

It optionally accepts a list of modules that you want it to support. The default list is everything that ships with the package and is available from the "->default_modules" method. There are two reasons that you might want to specify these:

1. You've written your own extension module and you want it loaded.

2. You know ahead of time with certainty what type of feeds you will be parsing and what extensions they will be using. Reducing the module list to just those you'll need will likely improve performance.

->parse

This is both a class and an object method. It accepts a string as its only argument. It returns a Feed::Parser::Result object. Please see the documentation on that module for details.

->default_modules

Returns a list of modules that are loaded by default.

->modules

Sets the list of modules to use when parsing. This is called automatically by new and thus would only normally be needed if you wanted to change the list later on.

PRIVATE METHODS

I do intend to document these, I just haven't gotten to them yet.

This class inherits from XML::SAX::Base. It overrides the following SAX methods:

->characters

->start_element

->end_element

->warning

->error

->fatal_error

It also has a whole bunch of methods that are used during the parsing of feeds.

->element_class

->result_class

->feed_class

->item_class

->bozo

->uri

->base

->lang

->set_parent_base

->set_parent_lang

->tag

->parent

->path

->full_path

->append_text

->get_attr

->hashify_tag

->stringify_content

->process_match

SEE ALSO

XML::SAX::Base XML::Atom XML::RSS XML::RAI XML::Feed

AUTHOR

Andy Turner, <turnera@cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2005 by Andy Turner

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.4 or, at your option, any later version of Perl 5 you may have available.

<<