NAME

App::Rssfilter::Filter::DeleteItem - remove an RSS item from its channel

VERSION

version 0.07

SYNOPSIS

  use App::Rssfilter::Filter::MarkTitle;

  use Mojo::DOM;
  my $rss = Mojo::DOM->new( <<"End_of_RSS" );
<?xml version="1.0" encoding="UTF-8"?>
<rss>
<channel>
  <item><title>it's hi time</title><description>hi</description></item>
  <item><title>here we are again</title><description>hello</description></item>
</channel>
</rss>
End_of_RSS

  $rss->find( 'item' )->each(
      sub {
        my $item = shift;
        if( $item =~ /hello/ ) {
          App::Rssfilter::Filter::DeleteItem::filter( $item );
        }
      }
  );

  # or with an App::Rssfilter::Rule

  use App::Rssfilter::Rule;
  App::Rssfilter::Rule->new(
      condition => sub { shift =~ m/hello/xms },
      action    => 'DeleteItem',
  )->constrain( $rss );

  # either way
  print $rss->to_xml;

  # <?xml version="1.0" encoding="UTF-8"?>
  # <rss>
  #   <channel>
  #     <item><title>it&#39;s hi time</title>hi</item>
  #   </channel>
  # </rss>

DESCRIPTION

This module will remove an RSS item from its channel. Actually, it will remove any Mojo::DOM element from its parent. Use App::Rssfilter::Filter::MarkTitle for a non-destructive filter.

FUNCTIONS

filter

App::Rssfilter::Filter::DeleteItem::filter( $item, $matcher );

Removes $item from its parent and discards it.

$matcher is an optional string specifying the condition which caused $item to be removed, and is ignored; it exists solely so that "constrain" in App::Rssfilter::Rule can set it to the name of the condition causing the match.

SEE ALSO

AUTHOR

Daniel Holz <dgholz@gmail.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2013 by Daniel Holz.

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