Timothy Appnel > XML-RSS-Parser-1 > XML::RSS:Parser

Download:
XML-RSS-Parser-1.tar.gz

Annotate this POD

CPAN RT

Open  6
View Bugs
Report a bug
Source   Latest Release: XML-RSS-Parser-1.02

NAME ^

XML::RSS:Parser - A liberal object-oriented parser for RSS feeds.

SYNOPSIS ^

#!/usr/bin/perl -w

        use strict;
        use XML::RSS::Parser;
        use URI;
        use LWP::UserAgent;
        use Data::Dumper;
        
        my $ua = LWP::UserAgent->new;
        $ua->agent('XML::RSS::Parser Test Script');
        my @places=( 'http://www.timaoutloud.org/xml/index.rdf' );
        
        my $p = new XML::RSS::Parser;
        
        foreach my $place ( @places ) {
        
                # retreive feed
                my $url=URI->new($place);
                my $req=HTTP::Request->new;
                $req->method('GET');
                $req->uri($url);
                my $feed = $p->parse($ua->request($req)->content);
                
                # output some values
                my $title = XML::RSS::Parser->ns_qualify('title',$feed->rss_namespace_uri);
                print $feed->channel->type.": ".$feed->channel->element($title)->value."\n";
                print "item count: ".$feed->item_count()."\n";
                foreach my $i ( @{ $feed->items } ) {
                        foreach ( keys %{ $i->element } ) {
                                print $_.": ".$i->element($_)->value."\n";
                        }
                        print "\n";
                }
                
                # data dump of the feed to screen.
                my $d = Data::Dumper->new([ $feed ]);
                print $d->Dump."\n\n";
        
        }

DESCRIPTION ^

XML::RSS::Parser is a lightweight liberal parser of RSS feeds that is derived from the XML::Parser::LP module the I developed for mt-rssfeed -- a MovableType plugin. This parser is "liberal" in that it does not demand compliance to a specific RSS version and will attempt to gracefully handle tags it does not expect or understand. The parser's only requirements is that the file is well-formed XML and remotely resembles RSS. The module is leaner then XML::RSS -- the majority of code was for generating RSS files.

Your feedback and suggestions are greatly appreciated. See the TO DO section for some brief thoughts on next steps.

This modules requires the XML::Parser package.

METHODS ^

The following methods are available:

XML::RSS::Parser::Feed ^

XML::RSS::Parser::Feed is a simple object that holds the results of a parsed RSS feed.

XML::RSS::Parser::Block ^

XML::RSS::Parser::Block is an object that holds the contents of a RSS block. Block objects can be of type channel, item or image. Block objects maintain a stack and a mapping of objects to their namespace qualified element names.

XML::RSS::Parser::Element ^

XML::RSS::Parser::Element is an object that represents one tag or tagset in an RSS block.

DEPENDENCIES ^

XML::Parser

SEE ALSO ^

XML::Parser, http://feeds.archive.org/validator/, http://www.xml.com/pub/a/2002/12/18/dive-into-xml.html, http://www.oreillynet.com/pub/a/webservices/2002/11/19/rssfeedquality.html,

TO DO AND ISSUES ^

LICENSE ^

The software is released under the Artistic License. The terms of the Artistic License are described at http://www.perl.com/language/misc/Artistic.html.

AUTHOR & COPYRIGHT ^

Except where otherwise noted, XML::RSS::Parser is Copyright 2003, Timothy Appnel, self@timaoutloud.org. All rights reserved.