#!/usr/bin/perl -W
use strict;
use XML::RSS::SimpleGen;
use XML::LibXML;
use IO::File;

my $inputfile="/home/olaf/Bert/rss_source.xml";
my $url = q<http://bert.secret-wg.org/>;
my $rss = XML::RSS::SimpleGen->new( $url, "Bert Goes Places RSS Feed","A semi-manually maintained RSS feed for the Bert Goes Places site");
$rss->language( 'en' );
$rss->get_url( $url );
$rss->history_file( "/home/olaf/Bert/rss-gen/BertsRSSHistory.dat" );
$rss->weekly();
$rss->get_url( $url );
  


my $parser=XML::LibXML->new();

open(IN,"< $inputfile")|| die "Could not open inputfile";
my $instring;
while (<IN>){
    $instring.=$_;
}

my $doc=$parser->parse_string($instring);
my $root=$doc->getDocumentElement; 
my $item;
foreach  $item ( $root->findnodes('item')) {
    my @title=$item->findnodes("title");
    my @description=$item->findnodes("description");
    my @link=$item->findnodes("link");
    my $descr=$description[0]->serialize();
    $rss->item($link[0]->findvalue("."),
	       $title[0]->findvalue("."),
	       \$descr);

}

die "No items in this content?! {{\n$_\n}}\nAborting"
    unless $rss->item_count();
  
print "Content-type: application/xml\n\n", $rss->as_string();
exit;

