Michael J. Mathews > Blog-BlogML-Reader-1.03 > Blog::BlogML::Reader

Download:
Blog-BlogML-Reader-1.03.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 1.03   Source  

NAME ^

Blog::BlogML::Reader - read data from a BlogML formatted document

SYNOPSIS ^

  use Blog::BlogML::Reader;
  
  my $reader = new Blog::BlogML::Reader('some/file/blogml.xml');
  my @posts = @{$reader->posts()};

DEPENDENCIES ^

EXPORT ^

None.

INTERFACE ^

filters

When creating a new reader, the default bahaviour is to parse and return every post in the entire BlogML file. This can be inefficient if, for example, you have ten-thousand posts and only want the first one. For this reason it is recommended that you give the parser some limits. This is done by adding "filters" to the constructor call. Note that once a reader is constructed it's filters cannot be modified; you must create a new reader if you wish to apply new filters.

methods

EXAMPLE ^

        use Blog::BlogML::Reader;
        use Date::Format;

        # parse all posts in the month of April
        my $reader = new Blog::BlogML::Reader('t/example.xml',
          after  => "2006-04-01T00:00:00",
          before => "2006-05-01T00:00:00",
        );

        my $posts = $reader->posts();
        my $meta  = $reader->meta();
        my $cats  = $reader->cats();

        print "<h1>", $meta->{title}, "</h1>";
        print $meta->{author};

        foreach my $post (@$posts) {
          print "<h2>", $post->{title}, "</h2>";

          # post dates are returned in Unix time, so format as desired
          print "posted:", time2str("%o of %B %Y", $post->{time});

          print " categories:",
          join(", ",  map{$cats->{$_}{title}} @{$post->{cats}});

          print " link:", $post->{url};

          print $post->{content}, "<hr />";
        }

SEE ALSO ^

The website http://BlogML.com has the latest documentation on the BlogML standard. Note that the reference document "t/example.xml" included with this distribution illustrates the expected format of BlogML documents used by this module.

AUTHOR ^

Michael Mathews, <mmathews@cpan.org>

COPYRIGHT AND LICENSE ^

Copyright (C) 2006 by Michael Mathews

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.6 or, at your option, any later version of Perl 5 you may have available.

syntax highlighting: