###############################################
# Author : Suresh S
#
# Version:0.0.1a
#
# PexlReader
################################################
#---------------------------------------------------------------------------------------
# This Program Traces BBC NEWS and
# and Retrieves RSS feed
#
# @ Return title,link,pubDate,description
#
#---------------------------------------------------------------------------------------
#!/usr/bin/perl -w
use strict;
use warnings;
use LWP::UserAgent;
use XML::Parser;
my $urlh= LWP::UserAgent->new;
my $urld = $urlh->get('http://newsrss.bbc.co.uk/rss/sportonline_world_edition/front_page/rss.xml');
if ($urld->is_success) {
my $ps = new XML::Parser(Handlers => {Start => \&handle_start,
End => \&handle_end, Char => \&handle_char });
$ps->parse($urld->content);
}
else {
die $urld->status_line;
}
sub handle_start {
my ($p, $elt, %atts) = @_;
my $msg;
if ($elt eq "title") {
# $msg = $atts{$_};
}
# print $p;
# print $msg;
# print $elt;
}
sub handle_end {
my ($p,$elt)=@_;
if ($elt eq "title") {
}
# print $p;
# print $elt;
}
sub handle_char{
my ($p,$con)=@_;
print $con unless $con !~ /\W/;
}
It looks like your start and end handlers don't do anything. Maybe you should remove them.
Also, for parsing RSS, you might like to look at XML::RSS.
"The first rule of Perl club is you do not talk about
Perl club."
-- Chip Salzenberg
If something claims to be XML but isn't for some reason, then you should pass those problems back to the people creating the XML.
I'm pretty sure that the BBC would be very interested in hearing of any problems with their RSS feeds.
"The first rule of Perl club is you do not talk about
Perl club."
-- Chip Salzenberg
perlmonks.org content © perlmonks.org and davorg, simon.proctor, ssuresh83
prlmnks.org © 2006 edmund von der burg (eccles & toad)
v 0.03