in reply to Complex XML hash to csv

Hello CSharma,

only two remarks. First do not use XML::Simple anymore. As stated in the module's documentation it's use is deprecated. Personally i choosed XML::Twig and I'm happy with it. Specially if your xml data is big and complex you'll enjoy the ability of XML::Twig to parse XML using handlers. Might be that your case is few lines of Perl codes and one line of XML::Twig handler.

Second point the below lines of your codes does not make much sense to me:
foreach my $d (keys %{$doc->{'results'}{'result'}{'output'}{'products' +}{'product'}}) { print $doc->{'results'}{'result'}{'output'}{'products'}{'produ +ct'}{'image_link'} . "\n"; }
I read this like "foreach sheep in sheep_group print name_of_every_sheep_in_the_farm"
Why do you not use $d ?
Perhaps you intend something like (i admit i have not seen your big hash..)
foreach my $d (keys %{$doc->{'results'}{'result'}{'output'}{'products' +}{'product'}}) { print $d->{'image_link'} . "\n"; #UPDATE (was: $d{'image_link +'} ) spotted by choroba (thanks) .. i was sure i put }
HtH
L*
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Replies are listed 'Best First'.
Re^2: Complex XML hash to csv
by Preceptor (Deacon) on Oct 23, 2015 at 09:43 UTC