1 # $Id: Entry.pm 1865 2005-08-09 20:15:31Z btrott $
3 package XML::Feed::Entry;
5 use base qw( Class::ErrorHandler );
12 bless { entry => $item }, $class;
15 sub unwrap { $_[0]->{entry} }
21 my $format_class = 'XML::Feed::' . $format;
22 eval "use $format_class";
23 Carp::croak("Unsupported format $format: $@") if $@;
24 my $entry = bless {}, join('::', __PACKAGE__, $format);
25 $entry->init_empty or return $class->error($entry->errstr);
34 my $new = __PACKAGE__->new($format);
35 for my $field (qw( title link content summary category author id issued modified )) {
36 $new->$field($entry->$field());
56 XML::Feed::Entry - Entry/item in a syndication feed
60 ## $feed is an XML::Feed object.
61 for my $entry ($feed->entries) {
62 print $entry->title, "\n", $entry->summary, "\n\n";
67 I<XML::Feed::Entry> represents an entry/item in an I<XML::Feed> syndication
72 =head2 XML::Feed::Entry->new($format)
74 Creates a new I<XML::Feed::Entry> object in the format I<$format>, which
75 should be either I<RSS> or I<Atom>.
77 =head2 $entry->convert($format)
79 Converts the I<XML::Feed::Entry> object into the I<$format> format, and
80 returns the new object.
82 =head2 $entry->title([ $title ])
84 The title of the entry.
86 =head2 $entry->link([ $uri ])
88 The permalink of the entry, in most cases, except in cases where it points
89 instead to an offsite URI referenced in the entry.
91 =head2 $entry->content([ $content ])
93 Bn I<XML::Feed::Content> object representing the full entry body, or as
94 much as is available in the feed.
96 In RSS feeds, this method will look first for
97 I<http://purl.org/rss/1.0/modules/content/#encoded> and
98 I<http://www.w3.org/1999/xhtml#body> elements, then fall back to a
99 I<E<lt>descriptionE<gt>> element.
101 =head2 $entry->summary([ $summary ])
103 An I<XML::Feed::Content> object representing a short summary of the entry.
106 Since RSS feeds do not have the idea of a summary separate from the entry
107 body, this may not always be what you want. If the entry contains both a
108 I<E<lt>descriptionE<gt>> element B<and> another element typically used for
109 the full content of the entry--either I<http://www.w3.org/1999/xhtml/body>
110 or I<http://purl.org/rss/1.0/modules/content/#encoded>--we treat that as
111 the summary. Otherwise, we assume that there isn't a summary, and return
112 an I<XML::Feed::Content> object with an empty string in the I<body>.
114 =head2 $entry->category([ $category ])
116 The category in which the entry was posted.
118 =head2 $entry->author([ $author ])
120 The name or email address of the person who posted the entry.
122 =head2 $entry->id([ $id ])
124 The unique ID of the entry.
126 =head2 $entry->issued([ $issued ])
128 A I<DateTime> object representing the date and time at which the entry
131 If present, I<$issued> should be a I<DateTime> object.
133 =head2 $entry->modified([ $modified ])
135 A I<DateTime> object representing the last-modified date of the entry.
137 If present, I<$modified> should be a I<DateTime> object.
139 =head1 AUTHOR & COPYRIGHT
141 Please see the I<XML::Feed> manpage for author, copyright, and license