#!/usr/bin/perl -- use strict; use warnings; use Data::Dumper; use XML::Simple; my $xml = q~ Example 2.0 Channel with Enclosure sub-element of Item http://example.com/ To lead by example en-us All content Public Domain, except comments which remains copyright the author editor@example.com webmaster@example.com http://backend.userland.com/rss Reference/Libraries/Library_and_Information_Science/Technical_Services/Cataloguing/Metadata/RDF/Applications/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 22News for September the Second http://22example.com/2002/09/02 22other things happened today http://22example.com/2002/09/02/comments.html 22joeuser@22example.com Mon, 22 Sep 2002 03:19:00 GMT http://22example.com/2002/09/02 ~; $xml = XMLin( $xml, ForceArray => ['item'], ); local $Data::Dumper::Indent=1; print Dumper( $xml ),"\n"; my $items = $xml->{channel}{item}; for my $i( @$items ){ print $i->{enclosure}{url},"\n"; } __END__ $VAR1 = { 'version' => '2.0', 'channel' => { 'link' => 'http://example.com/', 'language' => 'en-us', 'ttl' => '60', 'item' => [ { 'enclosure' => { 'length' => '12216320', 'url' => 'http://www.scripting.com/mp3s/weatherReportSuite.mp3', 'type' => 'audio/mpeg' }, 'link' => 'http://example.com/2002/09/02', 'author' => 'joeuser@example.com', 'comments' => 'http://example.com/2002/09/02/comments.html', 'description' => 'other things happened today', 'title' => 'News for September the Second', 'guid' => { 'isPermaLink' => 'true', 'content' => 'http://example.com/2002/09/02' }, 'pubDate' => 'Mon, 02 Sep 2002 03:19:00 GMT' }, { 'enclosure' => { 'length' => '12216320', 'url' => 'http://www.22scripting.com/mp3s/22weatherReportSuite.mp3', 'type' => 'audio/mpeg' }, 'link' => 'http://22example.com/2002/09/02', 'author' => '22joeuser@22example.com', 'comments' => 'http://22example.com/2002/09/02/comments.html', 'description' => '22other things happened today', 'title' => '22News for September the Second', 'guid' => { 'isPermaLink' => 'true', 'content' => 'http://22example.com/2002/09/02' }, 'pubDate' => 'Mon, 22 Sep 2002 03:19:00 GMT' } ], 'copyright' => 'All content Public Domain, except comments which remains copyright the author', 'description' => 'To lead by example', 'generator' => 'The Superest Dooperest RSS Generator', 'lastBuildDate' => 'Mon, 02 Sep 2002 03:19:17 GMT', 'category' => { 'domain' => 'http://www.dmoz.org', 'content' => 'Reference/Libraries/Library_and_Information_Science/Technical_Services/Cataloguing/Metadata/RDF/Applications/RSS/' }, 'title' => 'Example 2.0 Channel with Enclosure sub-element of Item', 'webMaster' => 'webmaster@example.com', 'docs' => 'http://backend.userland.com/rss', 'managingEditor' => 'editor@example.com' } }; http://www.scripting.com/mp3s/weatherReportSuite.mp3 http://www.22scripting.com/mp3s/22weatherReportSuite.mp3