The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

XML::Atom::Categories - Atom Category Document object

SYNOPSIS

  use XML::Atom::Categories;

  my $category = XML::Atom::Category->new;
  $category->scheme('http://example.org/extra-cats/');
  $category->term('joke');

  my $categories = XML::Atom::Categories->new;
  $categories->href('http://example.com/cats/forMain.cats');
  $categories->add_category($category);

  my $xml = $categories->as_xml;

  ## Get a list of the category elements.
  my @category = $categories->category;

DESCRIPTION

Category Documents contain lists of categories described using the "atom:category" element from the Atom Syndication Format [RFC4287].

The Category Document is defined in "The Atom Publishing Protocol," IETF Internet-Draft.

USAGE

XML::Atom::Categories->new([ $stream ])

Creates a new Category Document object, and if $stream is supplied, fills it with the data specified by $stream.

Automatically handles autodiscovery if $stream is a URI (see below).

Returns the new XML::Atom::Categories object. On failure, returns undef.

$stream can be any one of the following:

  • Reference to a scalar

    This is treated as the XML body of the feed.

  • Scalar

    This is treated as the name of a file containing the Category Document XML.

  • Filehandle

    This is treated as an open filehandle from which the Category Document XML can be read.

  • URI object

    This is treated as a URI, and the Category Document XML will be retrieved from the URI.

$categories->category

If called in scalar context, returns an XML::Atom::Category object corresponding to the first <category> element found in the Category Document.

If called in list context, returns a list of XML::Atom::Category objects corresponding to all of the <category> elements found in the Service Document.

$service->add_category($category)

Adds the category $category, which must be an XML::Atom::Category object, to the Service Document as a new <category> element. For example:

    my $category = XML::Atom::Category->new;
    $category->term('joke');
    $categories->add_category($category);

$categories->fixed

$categories->scheme

$categories->href

SEE ALSO

XML::Atom

XML::Atom::Service

AUTHOR

Takeru INOUE, <takeru.inoue@gmail.com>

COPYRIGHT AND LICENSE

Copyright (C) 2007 by Takeru INOUE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.