in reply to Re: XML parsing
in thread XML parsing

A quick and dirty fix is to just strip off any leading "::" before printing:

sub parsetree { my $ref = shift; my $txt = shift; foreach my $key ( keys %{$ref} ) { if( ref( $$ref{$key} ) =~ /HASH/ ) { parsetree( $$ref{$key}, $txt."::".$key ); } else { my $out = $txt . '::' . $key . '::' . $$ref{$key} . "\n"; $out =~ s/^:://; print $out; } } }

This will produce (Update: closer to) the requested output, so long as "order" doesn't matter.


Dave

Replies are listed 'Best First'.
Re^3: XML parsing
by hdb (Monsignor) on Mar 25, 2013 at 08:54 UTC
    There is one more difference to the requested output. The currency (INR) and the amount (234.00) are given as separate lines. This results from the way XML::Simple deals with <tag name=value>.