use strict; use warnings; use Test::More tests => 6; use XML::RSS; use constant RSS_VERSION => "2.0"; use constant RSS_CHANNEL_TITLE => "Example 2.0 Channel"; use constant RSS_DOCUMENT => qq( Example 2.0 Channel http://example.com/ To lead by example en-us editor\@example.com webmaster\@example.com http://backend.userland.com/rss The Superest Dooperest RSS Generator Mon, 02 Sep 2002 03:19:17 GMT 60 News for September the Second http://example.com/2002/09/02 other things happened today http://example.com/2002/09/02/comments.html joeuser\@example.com Mon, 02 Sep 2002 03:19:00 GMT http://example.com/2002/09/02 ); { my $xml = XML::RSS->new(); # TEST isa_ok($xml,"XML::RSS"); eval { $xml->parse(RSS_DOCUMENT); }; # TEST is($@,'',"Parsed RSS feed"); # TEST is_deeply($xml->{items}->[0]->{enclosure}, { url => "http://example.com/test2.mp3", length => "5352283", type => "audio/mpeg" }, "got enclosure"); } { my $xml = XML::RSS->new; eval { $xml->parse(RSS_DOCUMENT, { allow_multiple => [ 'enclosure' ] } ) }; # TEST is($@,'',"Parsed RSS feed again"); # TEST is_deeply($xml->{items}->[0]->{enclosure}->[0], { url => "http://example.com/test.mp3", length => "5352283", type => "audio/mpeg" }, "got first enclosure" ); # TEST is_deeply($xml->{items}->[0]->{enclosure}->[1], { url => "http://example.com/test2.mp3", length => "5352283", type => "audio/mpeg" }, "got second enclosure" ); }