Painless RSS processing with Mojo

I wasn't looking forward to dealing with this XML feed because I hate anything that deals with XML. However, with Mojo's DOM stuff, I don't even have to know it's XML. Here's the interesting bits from a program that's not much larger than this snippet:

use Mojo::UserAgent;

my $ua = Mojo::UserAgent->new;
my $response = $ua->get( $feed_address )->res;

my @links = $response->
dom( 'item' )->
grep( sub { $_->children( 'title' ) !~ /.../ } )->
map( sub {
$_->
children('guid')->
map( sub { $_->text } )
} )->
each
;

2 Comments

Yeah. I just love Mojo's jquery alike syntax.

To view rss xml online this tool may help http://codebeautify.org/rssviewer

Leave a comment

About brian d foy

user-pic I'm the author of Mastering Perl, and the co-author of Learning Perl (6th Edition), Intermediate Perl, Programming Perl (4th Edition) and Effective Perl Programming (2nd Edition).