in reply to Re: Reading multi-level-tag XML file
in thread Reading multi-level-tag XML file

Thanks Choroba! That worked. I want output like below, but getting unexpected results. All location values of all tags are coming for all seller entries. Something here is messy, Could you please help? sellerid comma seperated locations i.e. 426089 NY, CA, FL
for my $inf (@{$data->{'SellerInformation'}}) { $sellerid = $inf->{'Seller'}[0]{'sellerIdFromProvider'}; $i = 0; for my $loc (@{$inf->{'TaxableLocationsCollection'}[0]{'TaxableLocatio +n'}}) { $location[$i++] = $loc->{'locationValue'}; } $location{$sellerid} = join(", ", @location); print $sellerid, "\t" . $location{$sellerid} . "\n"; }

Replies are listed 'Best First'.
Re^3: Reading multi-level-tag XML file
by poj (Abbot) on Jul 27, 2015 at 19:57 UTC

    You are not clearing the @location array for each Seller. Try

    for my $inf (@{$data->{'SellerInformation'}}) { my $sellerid = $inf->{'Seller'}[0]{'sellerIdFromProvider'}; my @location=(); for my $loc (@{$inf->{'TaxableLocationsCollection'}[0]{'TaxableLocat +ion'}}) { push @location,$loc->{'locationValue'}; } print $sellerid."\t" .join(", ", @location)."\n"; }
    poj
      Thanks poj, got the required data!