techtween has asked for the wisdom of the Perl Monks concerning the following question:
Hi Perl monks, sorry to ask a so simple question, but ihave been dodging with it for some hours.I have an XML file of the form,
<?xml version="1.0" encoding="UTF-8"?> <testResults version="1.2"> <httpSample t="704" lt="704" ts="1306146504248" s="true" lb="HTTP Requ +est" rc="200" rm="OK" tn="Thread Group 2-1" dt="text" by="411"/> <httpSample t="525" lt="525" ts="1306146505234" s="true" lb="HTTP Requ +est" rc="200" rm="OK" tn="Thread Group 2-2" dt="text" by="411"/> <httpSample t="526" lt="526" ts="1306146506234" s="true" lb="HTTP Requ +est" rc="200" rm="OK" tn="Thread Group 2-3" dt="text" by="411"/> <httpSample t="586" lt="586" ts="1306146611316" s="true" lb="HTTP Requ +est" rc="200" rm="OK" tn="Thread Group 2-1" dt="text" by="411"/> <httpSample t="523" lt="523" ts="1306146612307" s="true" lb="HTTP Requ +est" rc="200" rm="OK" tn="Thread Group 2-2" dt="text" by="411"/> <httpSample t="507" lt="507" ts="1306146613306" s="true" lb="HTTP Requ +est" rc="200" rm="OK" tn="Thread Group 2-3" dt="text" by="411"/> <httpSample t="554" lt="554" ts="1306146614306" s="true" lb="HTTP Requ +est" rc="200" rm="OK" tn="Thread Group 2-4" dt="text" by="411"/> <httpSample t="535" lt="535" ts="1306146615306" s="true" lb="HTTP Requ +est" rc="200" rm="OK" tn="Thread Group 2-5" dt="text" by="411"/> </testResults>
now i need to find and display the maximum and minimum of lt value of each set( that is maximum and minimum values of lt from first three tags seperated by a newline and the next five tags inside a single program also similarly display the average of the two sets. I was able to fetch the lt values alone and display, but somewhere i have made some sort of mistake which devoids me from obtaining the desired output. kindly help.. for your information the code i used is as follows(to get lt value),
use strict; use warnings; use XML::Simple; use Data::Dumper; # create object my $xml_data = new XML::Simple (KeyAttr=>[]); # read XML file my $file_path='c:\catalog1'; my $data = $xml_data->XMLin($file_path); # dereference hash reference # access <httpSample> array foreach my $e (@{$data->{httpSample}}) { my @values = $e->{lt}; print "Lt_Value: ", @values, "\n"; print "\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: find min, max and average
by bart (Canon) on May 24, 2011 at 11:11 UTC | |
by techtween (Novice) on May 24, 2011 at 12:08 UTC | |
by Anonymous Monk on May 25, 2011 at 05:17 UTC | |
by bart (Canon) on May 25, 2011 at 07:28 UTC | |
by techtween (Novice) on May 25, 2011 at 09:52 UTC | |
|
Re: find min, max and average
by Corion (Patriarch) on May 24, 2011 at 10:47 UTC | |
by techtween (Novice) on May 24, 2011 at 10:53 UTC | |
by Corion (Patriarch) on May 24, 2011 at 10:58 UTC |