| Text-Microformat documentation | Contained in the Text-Microformat distribution. |
Text::Microformat::Plugin::Parser::RSS - RSS parser plugin for Text::Microformat
Keith Grennan, <kgrennan at cpan.org>
Log bugs and feature requests here: http://code.google.com/p/ufperl/issues/list
Project homepage: http://code.google.com/p/ufperl/
Copyright 2007 Keith Grennan, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| 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;