I'm having a very hard time deciphering your question but I think you (may) want something like this. It does not keep the exact XML formatting but that is something that is lost when XML::Simple parses it.
use strict; use warnings; use XML::Simple; my $xml = new XML::Simple; my $data = $xml->XMLin( \*DATA ); my %by_code; foreach my $dtc ( @{ $data->{DTC} } ) { push @{ $by_code{ $dtc->{TroubleCode} } }, $dtc; } foreach my $code ( sort { $a <=> $b } keys %by_code ) { print "trouble code: $code\n"; print "description:\n"; print map { $xml->XMLout( $_, RootName => 'DTC', NoAttr => 1, ) } @{ $by_code{$code} }; } __DATA__ <xml> Removed by request. </xml>
In reply to Re: perl script to print xml data like this
by afresh1
in thread perl script to print xml data like this
by veerubiji
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |