I have XML from this link http://sapxi.dfssi.com/parser/book.xml
I want to get values from the first book
element. Any idea how to parse it in Perl?
use strict;
use warnings;
use Data::Dumper;
use XML::Simple;
use LWP::Simple;
my $parser = new XML::Simple;
my $url = 'http://sapxi.dfssi.com/parser/book.xml';
my $content = get $url or die "Unable to get $url\n";
my $data = $parser->XMLin($content);
print Dumper($data);
print $data->{book}{title}->[0];
I always get
Not a HASH reference at ./xml_parser.pl line 20.
All I want is to print the title Book 1 title
and the author value.
Output will be like this.
Book title: Book 1 title Author: Book 1 author 1, Book 1 author 2
Thanks in advance for helping.
it should be print $data->{book}->[0]->{title};