Text::Microformat::Plugin::Parser::RSS - RSS parser plugin for Text::Microformat


Text-Microformat documentation Contained in the Text-Microformat distribution.

Index


Code Index:

NAME

Top

Text::Microformat::Plugin::Parser::RSS - RSS parser plugin for Text::Microformat

SEE ALSO

Top

Text::Microformat

AUTHOR

Top

Keith Grennan, <kgrennan at cpan.org>

BUGS

Top

Log bugs and feature requests here: http://code.google.com/p/ufperl/issues/list

SUPPORT

Top

Project homepage: http://code.google.com/p/ufperl/

COPYRIGHT & LICENSE

Top


Text-Microformat documentation Contained in the Text-Microformat distribution.

package Text::Microformat::Plugin::Parser::RSS;
use strict;
use warnings;
use HTML::TreeBuilder;

# This plugin parses entity-encoded and CDATA 'description' elements from RSS,
# and inserts them into the tree.
sub parse {
    my $c = shift;
	$c->NEXT::parse(@_); # wait until the XML parser has run
	if ($c->tree and $c->opts->{content_type} =~ /xml/i and $c->tree->root->tag eq 'rss') {
		foreach my $e ($c->tree->look_down(_tag => $c->tag_regex('description'))) {
			my $subtree = $c->html_to_tree($e->as_trimmed_text);
			$e->delete_content;
			$e->push_content($subtree->root->clone);
			$subtree->delete;
		}
	}
}

1;