9 my $now = DateTime->now();
11 my $feed = XML::Feed->new('Atom');
13 $feed->description("Atom 1.0 feed");
14 $feed->link("http://example.org/");
15 $feed->id("tag:cpan.org;xml-feed-atom");
18 my $entry = XML::Feed::Entry->new('Atom');
19 $entry->title("1st Entry");
20 $entry->link("http://example.org/");
21 $entry->category("blah");
22 $entry->content("<p>Hello world.</p>");
23 $entry->id("tag:cpan.org;xml-feed-atom-entry");
24 $entry->updated($now);
26 $feed->add_entry($entry);
28 my $xml = $feed->as_xml;
29 like $xml, qr!<feed xmlns="http://www.w3.org/2005/Atom"!;
30 like $xml, qr!<content .*type="xhtml">!;
31 like $xml, qr!<div xmlns="http://www.w3.org/1999/xhtml">!;
34 $feed = XML::Feed->parse(\$xml);
35 is $feed->format, 'Atom';
36 is $feed->title, "foo";
37 is $feed->description, "Atom 1.0 feed";
38 is $feed->link, "http://example.org/";
39 is $feed->id, "tag:cpan.org;xml-feed-atom";
40 is "".$feed->updated, "".$now;
42 my @entries = $feed->entries;
46 is $entry->title, '1st Entry';
47 is $entry->link, 'http://example.org/';
48 is $entry->category, 'blah';
49 is $entry->content->type, 'text/html';
50 like $entry->content->body, qr!\s*<p>Hello world.</p>\s*!s;
52 is $entry->id, "tag:cpan.org;xml-feed-atom-entry";
53 is "".$entry->updated, "".$now;