星期一, 2月 05, 2007

rss XML::Simple

#!/usr/bin/perl

use strict;
use XML::Simple;
use LWP::Simple;
use Data::Dumper;

my $url = "http://newsrss.bbc.co.uk/rss/newsonline_world_edition/middle_east/rss.xml";


my $content = get($url);
warn "could not retrieve $url" unless $content;

my $simple = XML::Simple->new();
my $data = $simple->XMLin($content);
# DEBUG
#print Dumper($data) . "\n";


foreach my $result (@{$data->{channel}->{item}}){

print
join "\n",
$result->{title} . "\n",
$result->{description} . "\n\n";
}

沒有留言: