BBC News Reader
ssuresh83
created: 2006-03-23 08:12:13
###############################################
#	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/;
}

Re: BBC News Reader
created: 2006-03-23 08:55:54

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.

--
<http://dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg

Re^2: BBC News Reader
created: 2006-03-26 11:36:09
I also have to fetch BBC RSS at work. Just to note that you can't automatically throw their RSS at an XML parser. For some reason (laziness?) they don't always encode their content correctly. So you can often get titles with plain ampersands in (etc).

Easy to regex out first but. . . .
Re^3: BBC News Reader
created: 2006-03-27 03:21:56

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.

--
<http://dave.org.uk>

"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