How do you output an attribute using Perl and XML::Simple

sucky sucky go

New Member
\[code\]sub parse_xml{ my $xml_link = $_[0]; my $xml_content = get($xml_link) or warn "Cant get XML page of " . $xml_link . "\n"; if(!$xml_content){ return; } my $xml = XML::Simple->new(KeepRoot => 1); my $xml_data = http://stackoverflow.com/questions/10906521/$xml->XMLin($xml_content); my @items = $xml_data->{rss}{channel}->{item}; # print Dumper($xml_data); foreach my $item (@items) { if($item){ print Dumper($item); //This is the dump output print $item->{author}; #print $item ."\n"; } }}\[/code\]When I try to output the item's author I just get either \[code\]HASH(Memory Address)\[/code\] or \[code\]not a hash reference at ... line ...\[/code\]Am I doing this incorrectly? Why is it producing this error?Here is the dumper output.\[code\]$VAR1 = [ { 'link' => 'http://***.com/article/news/betty-white-credits-snickers-golden-opportunities/144290/#comments-67229', 'author' => {}, 'title' => 'By: ', 'pubDate' => 'Tue, 08 Jun 2010 12:47 EDT', 'description' => 'Interesting. At least SHE remembered the product that propelled her to recent recognition. When many people I know have commented on how they loved that Betty White Super Bowl spot, they can't recall the product. Ah, advertising.' }, { 'link' => 'http://***.com/article/news/betty-white-credits-snickers-golden-opportunities/144290/#comments-67167', 'author' => {}, 'title' => 'By: ', 'pubDate' => 'Mon, 07 Jun 2010 13:26 EDT', 'description' => 'Fun, fun, fun. A great attitude for all of us to take into our careers.' }, { 'link' => 'http://****.com/article/news/betty-white-credits-snickers-golden-opportunities/144290/#comments-67164', 'author' => 'username', 'title' => 'By: username', 'pubDate' => 'Mon, 07 Jun 2010 12:23 EDT', 'description' => 'Her appearance of the Comedy Central roast of William Shattner a couple of years ago was great... it seems like her willingness to be irreverent makes her more appealing to us all! www.adverspew.com' }, { 'link' => 'http://****.com/article/news/betty-white-credits-snickers-golden-opportunities/144290/#comments-67142', 'author' => {}, 'title' => 'By: ', 'pubDate' => 'Mon, 07 Jun 2010 09:50 EDT', 'description' => 'Solid interview. I will definitely be tuning into "Hot in Cleveland" next week. We ought to enjoy Ms. White's talents for as long as we have her. She's great!' } ];\[/code\]
 
Back
Top