in reply to perl script to print xml data like this
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>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: perl script to print xml data like this
by veerubiji (Sexton) on Oct 04, 2011 at 08:28 UTC | |
by afresh1 (Hermit) on Oct 04, 2011 at 17:43 UTC | |
by veerubiji (Sexton) on Oct 05, 2011 at 07:16 UTC | |
|
Re^2: perl script to print xml data like this
by veerubiji (Sexton) on Oct 06, 2011 at 18:37 UTC | |
by afresh1 (Hermit) on Oct 06, 2011 at 20:19 UTC | |
by veerubiji (Sexton) on Oct 07, 2011 at 07:33 UTC |