XML::FeedLite::Normalised - XML::FeedLite::Normalised documentation


XML-FeedLite documentation Contained in the XML-FeedLite distribution.

Index


Code Index:

NAME

Top

XML::FeedLite::Normalised

VERSION

Top

$Revision: 1.4 $

SYNOPSIS

Top

DESCRIPTION

Top

SUBROUTINES/METHODS

Top

entries - Data structure of processed feed entries

  my $hrEntries = $xfln->entries();

process_rss - Processor for RSS 1.0-format entries

  Used by X::FL::N::entries

  $xfln->process_rss([...]);

process_atom - Processor for Atom-format entries

  Used by X::FL::N::entries

  $xfln->process_atom([...]);

DIAGNOSTICS

Top

CONFIGURATION AND ENVIRONMENT

Top

DEPENDENCIES

Top

INCOMPATIBILITIES

Top

BUGS AND LIMITATIONS

Top

AUTHOR

Top

Roger Pettett, <rmp@psyphi.net>

LICENSE AND COPYRIGHT

Top


XML-FeedLite documentation Contained in the XML-FeedLite distribution.

#########
# Author:        rmp@psyphi.net
# Maintainer:    rmp@psyphi.net
# Created:       2006-06-08
# Last Modified: $Date: 2009/01/09 14:38:54 $
# Id:            $Id: Normalised.pm,v 1.4 2009/01/09 14:38:54 zerojinx Exp $
# Source:        $Source: /cvsroot/xml-feedlite/xml-feedlite/lib/XML/FeedLite/Normalised.pm,v $
# $HeadURL$
#
package XML::FeedLite::Normalised;
use strict;
use warnings;
use base qw(XML::FeedLite);

our $VERSION  = do { my @r = (q$Revision: 1.4 $ =~ /\d+/smxg); sprintf '%d.'.'%03d' x $#r, @r };

sub entries {
  my ($self, @args) = @_;
  my $rawdata = $self->SUPER::entries(@args);

  for my $feed (keys %{$self->{'format'}}) {
    my $format = $self->{'format'}->{$feed};

    if($format !~ /^(atom|rss)/smx) {
      next;
    }

    my $method = "process_$format";

    $self->$method($rawdata->{$feed});
  }
  return $rawdata;
}

sub process_rss {
  my ($self, $feeddata) = @_;

  for my $entry (@{$feeddata}) {
    %{$entry} = (
		 'title'   => $entry->{'title'}->[0]->{'content'}       ||q(),
		 'content' => $entry->{'description'}->[0]->{'content'} ||q(),
		 'author'  => $entry->{'dc:creator'}->[0]->{'content'}  ||q(),
		 'date'    => $entry->{'dc:date'}->[0]->{'content'}     ||q(),
		 'link'    => [map { $_->{'content'}||q() } @{$entry->{'link'}}],
		);
  }
  return;
}

sub process_atom {
  my ($self, $feeddata) = @_;

  for my $entry (@{$feeddata}) {
    %{$entry} = (
		 'title'   => $entry->{'title'}->[0]->{'content'}   ||q(),
		 'content' => $entry->{'content'}->[0]->{'content'} ||q(),
		 'author'  => $entry->{'author'}->[0]->{'content'}  ||q(),
		 'date'    => $entry->{'updated'}->[0]->{'content'} ||q(),
		 'link'    => [map { $_->{'href'}||q() } @{$entry->{'link'}}],
		);
  }
  return;
}

1;

__END__