in reply to Converting XML to array of array.

Use Data::Dumper to visualise the structure you want to iterate over. You need to supply the root element name at the top: book . The following should give you a clue:

for my $id (keys %{ $xml->{book} }) { for my $s (keys %{ $xml->{book}{$id} }) { print "$s: @{ $xml->{book}{$id}{$s} }\n"; } }

Also, don't use XML::Simple.

Here's how to process the XML in XML::XSH2:

open file.xml ; for //book echo (title) edition (edition) by (authors/author/firstname | authors/author/lastname) '(' isbn (isbn) ')' ;

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Replies are listed 'Best First'.
Re^2: Converting XML to array of array.
by GotToBTru (Prior) on Jan 23, 2017 at 14:00 UTC

    Homework exercise probably specifies using XML::Simple or XML::Parser. It may prove useful to know about better alternatives, just not at the moment.

    But God demonstrates His own love toward us, in that while we were yet sinners, Christ died for us. Romans 5:8 (NASB)