use strict;
use warnings;
use XML::Simple;
my $xml = <<'END';
Aston Clinton
Andy Barth
1
GB
ANDY BARTH
Aylesbury
Daniele Dall'Acqua
2
GB
DANIELE DALL'ACQUA
Calne
Nigel Drew
3
GB
NIGEL DREW
END
my $xml_to_hash = XMLin(
$xml,
ForceArray => 1,
KeyAttr => {},
);
for my $inventor ( @{ $xml_to_hash->{inventor} } ) {
if ( $inventor->{number}[0]{content} == 1 ) {
while ( my ( $key, $value ) = each %{$inventor} ) {
print "$key => @$value[0]\n" if $key ne 'number';
}
}
}
####
country => GB
city => Aston Clinton
upper-name => ANDY BARTH
name => Andy Barth
##
##
[ ] = array
{ } = hash