
XML::Generator::RSS10 - Generate SAX events for RSS

version 0.02

use XML::Generator::RSS10;
my $rss = XML::Generator::RSS10->new( Handler => $sax_handler );
$rss->item( title => 'Exciting News About my Pants!',
link => 'http://pants.example.com/my/news.html',
description => 'My pants are full of ants!',
);
$rss->channel( title => 'Pants',
link => 'http://pants.example.com/',
description => 'A fascinating pants site',
);

This module generates SAX events which will create an RSS 1.0 document, based on easy to use RSS-related methods like item() and channel().

This is the constructor for this class.
It takes several parameters, though only one, "Handler", is required:
This should be a SAX2 handler. If you are looking to write RSS to a file or store it in a string, you probably want to use XML::SAX::Writer.
This parameter is required.
If this is true, the generated XML document will include extra spaces and newlines in an effort to make it look pretty. This defaults to false.
This parameter can be used to make additional RSS 1.0 modules available when creating a feed. It should be an array reference to a list of module prefixes.
You can specify any prefix you like, and this module will try to load a module named XML::Generator::RSS10::<prefix>.
This module comes with support for the core RSS 1.0 modules, which are Content (content), Dublin Core (dc), and Syndication (sy). It also include a module supporting the proposed Administrative (admin) and Creative Commons (cc) modules. See the docs for XML::Generator::RSS10::content, XML::Generator::RSS10::dc, XML::Generator::RSS10::sy, XML::Generator::RSS10::admin, and XML::Generator::RSS10::cc for details on how to use them.
The Dublin Core and Syndication modules are loaded by default if this parameter is not specified.
The constructor begins the RSS document and returns a new XML::Generator::RSS10 object.
This method is used to add item elements to the document. It accepts the following parameters:
The item's title. Required.
The item's link. Required.
The item's link. Optional.
This element will be formatted as CDATA since many people like to put HTML in it.
This method is used to add an image element to the document. It may only be called once. It accepts the following parameters:
The image's title. Required.
The image's link. Required.
The image's URL. Required.
This method is used to add an textinput element to the document. It may only be called once. It accepts the following parameters:
The textinput's title. Required.
The textinput's description. Required.
The textinput's name. Required.
The textinput's URL. Required.
This method is used add the channel element to the document. It also finishes the document. You must have added at least one item to the document prior to calling this method.
You may not call any other methods after this one is called.
The channel's title. Required.
The channel's link. Required.
The channel's description. Required.
This element will be formatted as CDATA since many people like to put HTML in it.

To add module output to a document, you can pass extra hash keys when calling any of the output-generating methods. The extra keys should be the module prefixes, and the values should be something expected by the relevant module.
For example, to add some Dublin Core elements to the channel element, you can write this:
$rss->channel( title => 'Pants',
link => 'http://pants.example.com/',
description => 'A fascinating pants site',
dc => { publisher => 'The Pants People',
rights => 'Mine, all mine!',
date => $date,
},
);
The values for the "dc" key will be passed to XML::Generator::RSS10::dc, which will add them to the output stream appropriately.

This module is less flexible than XML::RSS in many ways. However, it does have two features that XML::RSS does not provide:
XML::RSS requires you to create the entire document in memory first.However, if you don't need any of these features you may be better off using XML::RSS instead.

Please report any bugs or feature requests to bug-xml-generator-rss10@rt.cpan.org, or through the web interface at http://rt.cpan.org. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

Dave Rolsky <autarch@urth.org>

This software is Copyright (c) 2011 by Dave Rolsky.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)