<?xml version="1.0" encoding="ISO-8859-1" ?> <rss version="2.0"> <channel> <title>Used Cars fl</title> <link>http://usedcars.com</link> <language>en-us</language> <lastBuildDate>Thu, 14 Jun 2012 13:00:00 -0400</lastBuildDate> <copyright>Copyright 2012, West Palm Beach</copyright> <ttl>120</ttl> <item> <title><![CDATA[220 Used Cars]]></title> <pubDate>Wed, 16 May 2012 20:14:52 -0400</pubDate> <link>http://usedcars.com</link> <guid>http://usedcars.com</guid> <description>Description of used car.</description> </item> </channel> </rss> ******************************************************* Perl Code: use CGI qw/:standard/; use LWP::UserAgent; use XML::Simple; $XML::Simple::PREFERRED_PARSER = 'XML::Parser'; use Data::Dumper; $page=new CGI; use CGI::Carp 'fatalsToBrowser'; print $page->header; $xml = new XML::Simple (KeyAttr=>[''],NSExpand => 0,ForceArray=> 1); # read XML file $html="data_records2.txt"; $data =$xml->XMLin($html); open(FILE1,">data_out.txt"); print FILE1 Dumper($data); #if ($@) { warn "Error: $@\n"; #} $config_string='{channel}{item}'; foreach $e(@{eval("\$data->$config_string")}) { $count++; print $e->{title} ,$e->{description}, $e->{link}."\n"; } close(FILE1); exit; ############################################ Heres the output . Never gets to print data in the foreach loop. $VAR1 = { 'version' => '2.0', 'channel' => [ { 'link' => [ 'http://usedcars.com' ], 'lastBuildDate' => [ 'Thu, 14 Jun 2012 13:00:00 + -0400' ], 'language' => [ 'en-us' ], 'ttl' => [ '120' ], 'item' => [ { 'link' => [ 'http://usedcars.com' ], 'guid' => [ 'http://usedcars.com' ], 'title' => [ '220 Used Cars' ], 'description' => [ 'Description of +used car.' ], 'pubDate' => [ 'Wed, 16 May 2012 20 +:14:52 -0400' ] } ], 'copyright' => [ 'Copyright 2012, West Palm Bea +ch' ], 'title' => [ 'Used Cars fl' ] } ] }; ****************************************************** Thanks you Oh mighty perl Gods--- I mean Monks. This appears too ez. I + hang my head low in light of the great ones.
In reply to XML::Simple Array bombs out with 1 Item in document by roncoe2000
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |