note
afresh1
<p>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.</p>
<code>
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>
</code>
<div class="pmsig"><div class="pmsig-255189">
l8rZ,<br />
--<br />
andrew
</div></div>
929367
929367