GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
XML::FeedPP(3) User Contributed Perl Documentation XML::FeedPP(3)

XML::FeedPP -- Parse/write/merge/edit RSS/RDF/Atom syndication feeds

Get an RSS file and parse it:

    use XML::FeedPP ();
    my $source = 'http://use.perl.org/index.rss';
    my $feed = XML::FeedPP->new( $source );
    print "Title: ", $feed->title(), "\n";
    print "Date: ", $feed->pubDate(), "\n";
    foreach my $item ( $feed->get_item() ) {
        print "URL: ", $item->link(), "\n";
        print "Title: ", $item->title(), "\n";
    }

Generate an RDF file and save it:

    use XML::FeedPP ();
    my $feed = XML::FeedPP::RDF->new();
    $feed->title( "use Perl" );
    $feed->link( "http://use.perl.org/" );
    $feed->pubDate( "Thu, 23 Feb 2006 14:43:43 +0900" );
    my $item = $feed->add_item( "http://search.cpan.org/~kawasaki/XML-TreePP-0.02" );
    $item->title( "Pure Perl implementation for parsing/writing xml file" );
    $item->pubDate( "2006-02-23T14:43:43+09:00" );
    $feed->to_file( "index.rdf" );

Convert some RSS/RDF files to Atom format:

    use XML::FeedPP ();
    my $feed = XML::FeedPP::Atom::Atom10->new();        # create empty atom file
    $feed->merge( "rss.xml" );                          # load local RSS file
    $feed->merge( "http://www.kawa.net/index.rdf" );    # load remote RDF file
    my $now = time();
    $feed->pubDate( $now );                             # touch date
    my $atom = $feed->to_string();                      # get Atom source code

"XML::FeedPP" is an all-purpose syndication utility that parses and publishes RSS 2.0, RSS 1.0 (RDF), Atom 0.3 and 1.0 feeds. It allows you to add new content, merge feeds, and convert among these various formats. It is a pure Perl implementation and does not require any other module except for XML::TreePP.

This constructor method creates an "XML::FeedPP" feed instance. The only argument is the local filename. The format of $source must be one of the supported feed formats -- RSS, RDF or Atom -- or execution is halted.

The URL on the remote web server is also available as the first argument. LWP::UserAgent is required to download it.

The XML source code is also available as the first argument.

The "-type" argument allows you to specify type of $source from choice of 'file', 'url' or 'string'.

This makes utf8 flag on for all feed elements. Perl 5.8.1 or later is required to use this.

Note that any other options for "XML::TreePP" constructor are also allowed like this. See more detail on XML::TreePP.

This constructor method creates an instance for an RSS 2.0 feed. The first argument is optional, but must be valid an RSS source if specified. This method returns an empty instance when $source is undefined.

This constructor method creates an instance for RSS 1.0 (RDF) feed. The first argument is optional, but must be an RDF source if specified. This method returns an empty instance when $source is undefined.

This constructor method creates an instance for an Atom 0.3/1.0 feed. The first argument is optional, but must be an Atom source if specified. This method returns an empty instance when $source is undefined.

Atom 1.0 feed is also supported since "XML::FeedPP" version 0.30. Atom 0.3 is still default, however, future version of this module would create Atom 1.0 as default.

This creates an empty Atom 0.3 instance obviously.

This creates an empty Atom 1.0 instance intended.
This creates a RSS instance which has "link", "title" elements etc.

This method loads an RSS/RDF/Atom file, much like "new()" method does.

This method merges an RSS/RDF/Atom file into the existing $feed instance. Top-level metadata from the imported feed is incorporated only if missing from the present feed.

This method generates XML source as string and returns it. The output $encoding is optional, and the default encoding is 'UTF-8'. On Perl 5.8 and later, any encodings supported by the Encode module are available. On Perl 5.005 and 5.6.1, only four encodings supported by the Jcode module are available: 'UTF-8', 'Shift_JIS', 'EUC-JP' and 'ISO-2022-JP'. 'UTF-8' is recommended for overall compatibility.

This makes the output more human readable by indenting appropriately. This does not strictly follow the XML specification but does looks nice.

Note that any other options for "XML::TreePP" constructor are also allowed like this. See more detail on XML::TreePP.

This method generate an XML file. The output $encoding is optional, and the default is 'UTF-8'.
This method creates a new item/entry and returns its instance. A mandatory $link argument is the URL of the new item/entry.

This method duplicates an item/entry and adds it to $feed. $srcitem is a "XML::FeedPP::*::Item" class's instance which is returned by "get_item()" method, as described above.
This method creates an new item/entry which has "link", "title" elements etc.

This method returns item(s) in a $feed. A valid zero-based array $index returns the corresponding item in the feed. An invalid $index yields undef. If $index is undefined in array context, it returns an array of all items. If $index is undefined in scalar context, it returns the number of items.
This method finds item(s) which match all regular expressions given. This method returns an array of all matched items in array context. This method returns the first matched item in scalar context.
This method removes an item/entry specified by zero-based array index or link URL.

This method removes all items/entries from the $feed.

This method sorts the order of items in $feed by "pubDate".

Reduces the list of items, not to include duplicates. RDF and Atoms have a guid attribute to defined uniqueness, for RSS we use the link.

This method calls both the "sort_item()" and "uniq_item()" methods.

Removes items in excess of the specified numeric limit. Items at the end of the list are removed. When preceded by "sort_item()" or "normalize()", this deletes more recent items.

Adds an XML namespace at the document root of the feed.

Returns the URL of the specified XML namespace.

Returns the list of all XML namespaces used in $feed.

This method sets/gets the feed's "title" element, returning its current value when $title is undefined.

This method sets/gets the feed's "description" element in plain text or HTML, returning its current value when $html is undefined. It is mapped to "content" element for Atom 0.3/1.0.

This method sets/gets the feed's "pubDate" element for RSS, returning its current value when $date is undefined. It is mapped to "dc:date" element for RDF, "modified" for Atom 0.3, and "updated" for Atom 1.0. See also "DATE AND TIME FORMATS" section below.

This method sets/gets the feed's "copyright" element for RSS, returning its current value when $text is undefined. It is mapped to "dc:rights" element for RDF, "copyright" for Atom 0.3, and "rights" for Atom 1.0.

This method sets/gets the URL of the web site as the feed's "link" element, returning its current value when the $url is undefined.

This method sets/gets the feed's "language" element for RSS, returning its current value when the $lang is undefined. It is mapped to "dc:language" element for RDF, "feed xml:lang=""" for Atom 0.3/1.0.

This method sets/gets the feed's "image" element and its child nodes, returning a list of current values when any arguments are undefined.

This method sets/gets the item's "title" element, returning its current value when the $text is undefined.

This method sets/gets the item's "description" element in HTML or plain text, returning its current value when $text is undefined. It is mapped to "content" element for Atom 0.3/1.0.

This method sets/gets the item's "pubDate" element, returning its current value when $date is undefined. It is mapped to "dc:date" element for RDF, "modified" for Atom 0.3, and "updated" for Atom 1.0. See also "DATE AND TIME FORMATS" section below.

This method sets/gets the item's "category" element. returning its current value when $text is undefined. It is mapped to "dc:subject" element for RDF, and ignored for Atom 0.3.

This method sets/gets the item's "author" element, returning its current value when $name is undefined. It is mapped to "dc:creator" element for RDF, "author" for Atom 0.3/1.0.
This method sets/gets the item's "guid" element, returning its current value when $guid is undefined.

It is mapped to "id" element for Atom, and ignored for RDF. In case of RSS, it will return a HASH. The "isParmaLink" is supported by RSS only, and optional.

This method sets customized node values or attributes. See also "ACCESSOR AND MUTATORS" section below.

This method returns the node value or attribute. See also "ACCESSOR AND MUTATORS" section below.
This method returns the item's "link" element.

This module understands only subset of "rdf:*", "dc:*" modules and RSS/RDF/Atom's default namespaces by itself. There are NO native methods for any other external modules, such as "media:*". But "set()" and "get()" methods are available to get/set the value of any elements or attributes for these modules.

This sets the value of the child node:

    <item><module:name>$value</module:name>...</item>

This sets the value of the child node's attribute:

    <item><module:name attr="$value" />...</item>

This sets the value of the item's attribute:

    <item attr="$value">...</item>

This code sets the value of the child node's child node's attribute:

    <item><hoge><pomu attr="$value" /></hoge>...</item>

"XML::FeedPP" allows you to describe date/time using any of the three following formats:

This is the HTTP protocol's preferred format and RSS 2.0's native format, as defined by RFC 1123.

W3CDTF is the native format of RDF, as defined by ISO 8601.

The last format is the number of seconds since the epoch, "1970-01-01T00:00:00Z". You know, this is the native format of Perl's "time()" function.

To publish Media RSS, add the "media" namespace then use "set()" setter method to manipulate "media:content" element, etc.

    my $feed = XML::FeedPP::RSS->new();
    $feed->xmlns('xmlns:media' => 'http://search.yahoo.com/mrss/');
    my $item = $feed->add_item('http://www.example.com/index.html');
    $item->set('media:content@url' => 'http://www.example.com/image.jpg');
    $item->set('media:content@type' => 'image/jpeg');
    $item->set('media:content@width' => 640);
    $item->set('media:content@height' => 480);

"XML::FeedPP" requires only XML::TreePP which likewise is a pure Perl implementation. The standard LWP::UserAgent is required to download feeds from remote web servers. "Jcode.pm" is required to convert Japanese encodings on Perl 5.005 and 5.6.1, but is NOT required on Perl 5.8.x and later.

Yusuke Kawasaki, http://www.kawa.net/

The following copyright notice applies to all the files provided in this distribution, including binary files, unless explicitly noted otherwise.

Copyright 2006-2011 Yusuke Kawasaki

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
2018-04-20 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.