NAME

XML::RSS - creates and updates RSS files

SYNOPSIS

# create an RSS file
use XML::RSS;
$rss->channel(title => "freshmeat.net",
              link  => "http://freshmeat.net",
              description => "the one-stop-shop for all your Linux software needs"
              );

$rss->image(title => "freshmeat.net",
            url   => "http://freshmeat.net/images/fm.mini.jpg",
            link  => "http://freshmeat.net"
            );

$rss->add_item(title => "GTKeyboard 0.85",
               link  => "http://freshmeat.net/news/1999/06/21/930003829.html"
               );

$rss->textinput(title => "quick finder",
                description => "Use the text input below to search freshmeat",
                name  => "query",
                link  => "http://core.freshmeat.net/search.php3"
                );

# print the RSS as a string
print $rss->as_string;

# or save it to a file
$rss->save("fm.rdf");

# insert an item into an RSS file and removes the oldest item if
# there are already 15 items
my $rss = new XML::RSS;
$rss->parsefile("fm.rdf");
pop(@{$rss->{rss}->{'items'}}) if (@{$rss->{rss}->{'items'}} == 15);
$rss->add_item(title => "MpegTV Player (mtv) 1.0.9.7",
               link  => "http://freshmeat.net/news/1999/06/21/930003958.html",
               mode  => 'insert'
               );

# parse a string instead of a file
$rss->parse($string);

# print the title and link of each RSS item
foreach my $item (@{$rss->{rss}->{'items'}}) {
    print "title: $item->{'title'}\n";
    print "link: $item->{'link'}\n\n";
}

DESCRIPTION

This module provides a basic framework for creating and maintaining RDF Site Summary (RSS) files. This distribution also contains several examples that allow you to generate HTML from an RSS file. This might be helpful if you want to include news feeds on your Web site from sources like Slashot and Freshmeat.

RSS is primarily used by content authors who want to create a Netscape Netcenter channel, however, hat doesn't exclude us from using it in other applications. For example, you may want to distribute daily news headlines to partners and customers who convert it to some other format, like HTML.

For the most part the module adheres to the RSS spec as it exists at http://my.netscape.com/publish/help/quickstart.html. Unfortunately, the RSS spec also allows one to use any HTML entity without first declaring them. Since XML::RSS is based on XML::Parser, you can only use the default XML entities.

METHODS

new XML::RSS;

Constructor for XML::RSS. It returns a reference to an XML::RSS object.

add_item(title=>$title, link=>$link, mode=>$mode);

Adds an item to the XML::RSS object. mode is optional. The default mode is append, which adds the item to the end of the list. To insert an item, set the mode to insert.

The items are stored in the array @{$obj->{rss}->{'items'}} where $obj is a reference to an XML::RSS object.

as_string;

Returns a string containing the RSS for the XML::RSS object.

channel(title=>$title, link=>$link, description=>$desc);

Channel information is required for an RSS. The title cannot be more the 40 characters, the link 500, and the description 500.

To retreive the values of the channel, pass the name of the value (title, link, or description) as the first and only argument like so:

$title = channel('title');

image(title=>$title, url=>$url, link=>$link);

Adding an image is not required. url is the URL of the image, link is the URL the image is linked to.

The method for retrieving the values for the image is the same as it is for channel().

parse($string);

Parses an RDF Site Summary which is passed into parse() as the first parameter.

parsefile($file);

Same as parse() except it parses a file rather than a string.

save($file);

Saves the RSS to a specified file.

textinput(title=>$title, description=>$desc, name=>$name, link=>$link);

This RSS element is also optional. Using it allows users to submit a Query to a program on a Web server via an HTML form. name is the HTML form name and link is the URL to the program. Content is submitted using the GET method.

Access to the textinput values is the the same as channel() and image().

AUTHOR

Jonathan Eisenzopf <eisen@pobox.com>

SEE ALSO

perl(1), XML::Parser(3).

1 POD Error

The following errors were encountered while parsing the POD:

Around line 343:

You forgot a '=back' before '=head1'