SYNOPSIS

# Create an \s-1OPML\s0 file

 use XML::OPML;

 my $opml = new XML::OPML(version => "1.1");

 $opml->head(
             title => 'mySubscription',
             dateCreated => 'Mon, 16 Feb 2004 11:35:00 GMT',
             dateModified => 'Sat, 05 Mar 2004 09:02:00 GMT',
             ownerName => 'michael szul',
             ownerEmail => '[email protected]',
             expansionState => '',
             vertScrollState => '',
             windowTop => '',
             windowLeft => '',
             windowBottom => '',
             windowRight => '',
           );

 $opml->add_outline(
                 text => 'Warren Ellis Speaks Clever',
                 description => 'Warren Ellis\' Personal Weblog',
                 title => 'Warren Ellis Speaks Clever',
                 type => 'rss',
                 version => 'RSS',
                 htmlUrl => 'http://www.diepunyhumans.com ',
                 xmlUrl => 'http://www.diepunyhumans.com/index.rdf ',
               );

 $opml->add_outline(
                 text => 'raelity bytes',
                 descriptions => 'The raelity bytes weblog.',
                 title => 'raelity bytes',
                 type => 'rss',
                 version => 'RSS',
                 htmlUrl => 'http://www.raelity.org ',
                 xmlUrl => 'http://www.raelity.org/index.rss10 ',
               );

# Create embedded outlines

$opml->add_outline( opmlvalue => 'embed', outline_one => { text => 'The first embedded outline', description => 'The description for the first embedded outline', }, outline_two => { text => 'The second embedded outline', description => 'The description for the second embedded outline', }, outline_three => { opmlvalue => 'embed', em_outline_one => { text => 'I'm too lazy to come up with real examples', }, em_outline_two => { text => 'so you get generic text', }, }, );

# Create an embedded outline with attributes in the encasing <outline> tag

$opml->add_outline( opmlvalue => 'embed', description => 'now we can have attributes in this tag', title => 'attributes', outline_with_atts => { text => 'Eat Your Wheaties', description => 'Cereal is the breakfast of champion programmers', }, );

# Save it as a string.

$opml->as_string();

# Save it to a file.

$opml->save('mySubscriptions.opml');

# Update your \s-1OPML\s0 file.

use XML::OPML;

my $opml = new XML::OPML;

# Parse the file.

$opml->parse('mySubscriptions.opml');

# Or optionally from a variable.

my $content = $opml->as_string(); $opml->parse($content);

# Update it appending to the end of the outline

$opml->add_outline( text => 'Neil Gaiman\'s Journal', description =>'Neil Gaiman\'s Journal', title => 'Neil Gaiman\'s Journal', type => 'rss', version => 'RSS', htmlUrl => 'http://www.neilgaiman.com/journal/journal.asp ', xmlUrl => 'http://www.neilgaiman.com/journal/blogger_rss.xml ', );

# Update it inserting the outline into a specific group (note the group parameter)

$opml->insert_outline( group => 'occult', text => 'madghoul.com', description => 'the dark night of the soul', title => 'madghoul.com', type => 'rss', version => 'RSS', htmlUrl => 'http://www.madghoul.com ', xmlUrl => 'http://www.madghoul.com/cgi-bin/fearsome/fallout/index.rss10 ', );

DESCRIPTION

This experimental module is designed to allow for easy creation and manipulation of \s-1OPML\s0 files. \s-1OPML\s0 files are most commonly used for the sharing of blogrolls or subscriptions - an outlined list of what other blogs an Internet blogger reads. \s-1RSS\s0 Feed Readers such as AmphetaDesk ( http://www.disobey.com/amphetadesk ) use *.opml files to store your subscription information for easy access.

This is purely experimental at this point and has a few limitations. This module may now support attributes in the <outline> element of an embedded hierarchy, but these are limited to the following attributes: date_added, date_downloaded, description, email, filename, htmlurl, keywords, text, title, type, version, and xmlurl. Additionally, the following alternate spellings are also supported: dateAdded, dateDownloaded, htmlUrl, and xmlUrl.

Rather than reinvent the wheel, this module was modified from the \s-1XML::RSS\s0 module, so functionality works in a similar way.

METHODS

new \s-1XML::OPML\s0(version => '1.1')

This is the constructor. It returns a reference to an \s-1XML::OPML\s0 object. This will always be version 1.1 for now, so don't worry about it.

head(title => '$title', dateCreated => '$cdate', dateModified => '$mdate',ownerName => '$name', ownerEmail => '$email', expansionState => '$es', vertScrollState => '$vs', windowTop => '$wt', windowLeft => '$wl', windowBottom => '$wb',windowRight => '$wr',)

This method will create all the \s-1OPML\s0 tags for the <head> subset. For more information on these tags, please see the \s-1OPML\s0 documentation at http://www.opml.org . This method adds the <outline> elements to the \s-1OPML\s0 document(see the example above). There are no statement requirements for the attributes in this tag. The ones shown in the example are the ones most commonly used by \s-1RSS\s0 Feed Readers, blogrolls, and subscriptions. The opmlvalue element is optional. Only use this with the value 'embed' if you wish to embed another outline within the current outline. You can now use attributes in <outline> tags that are used for embedded outlines, however, you cannot use any attribute you want. The embedded <outline> tag only supports the following: date_added, date_downloaded, description, email, filename, htmlurl, keywords, text, title, type, version, and xmlurl, as well as the alternate spellings: dateAdded, dateDownloaded, htmlUrl, and xmlUrl. This method works in the same exact manner as add_outline() except that this will insert the outline element into the specified group. The $group variable must be the text presented in the \*(L"text\*(R" attribute of the outline that you wish to insert this one into. For example, if you have an outline element with the text attribute of \*(L"occult\*(R" that contains four outline subelements of occult web sites, your group parameter would be \*(L"occult.\*(R"

as_string()

Returns a string containing the \s-1OPML\s0 document.

save($file)

Saves the \s-1OPML\s0 document to $file

parse($content)

Uses XML::Parser and XML::SimpleObject to parse the value of the string or file that is passed to it. This method prepares your \s-1OPML\s0 file for a possible update. Embedded outlines are supported.

SOURCE AVAILABILITY

Source code is available at the development site at http://opml.blogenstein.com . Any contributions or improvements are greatly appreciated. You may also want to visit http://www.madghoul.com to see a whole lot of perl coding at work.

AUTHOR

michael szul <[email protected]>

COPYRIGHT

copyright (c) 2004 michael szul <[email protected]>

\s-1XML::OPML\s0 is free software. It may be redistributed and/or modified under the same terms as Perl.

CREDITS

michael szul <[email protected]> matt cashner <[email protected]> ricardo signes <[email protected]> gergely nagy <[email protected]>

RELATED TO XML::OPML…

perl\|(1), XML::Parser\|(3), XML::SimpleObject\|(3), \s-1XML::RSS\s0\|(3).