use XML::Simple qw(:strict);
use File::Find;
use strict;
use warnings;
use Carp;
use File::Find;
use XML::Parser;
use File::Spec::Functions qw( canonpath );
if ( @ARGV == 0 ) {
push @ARGV, "D:\\xml test";
warn "Using default path $ARGV[0]\n Usage: $0 path ...\n";
}
open(HTML_FILE, ">JBAT_Report.html") || die "Can't open file: $!\n";
# Print the initial HTML tags
print HTML_FILE "\n
\nBAT Report - JMeter Test
\n
TestPlan | Test Failed? | FailureMessage | Link to Source |
";
find(
sub {
return unless ( /[.]log\z/i and -f ); #getting multiple xml files with .log format
extract_information();
return;
},
@ARGV
);
sub extract_information {
my( $error, $value, $failure, $failureMessage ) = ("") x 4;
my $xmlFile = $_; # is this correct?
#print HTML_FILE $xmlFile;
my $xmlDocument = XMLin($xmlFile,
ForceArray => 1,
KeyAttr => {},
); # it shows error here
foreach my $httpSample (@{$xmlDocument->{httpSample}}) {
print HTML_FILE qq| $httpSample->{assertionResult}->[0]->{failure}->[0]\n|;
print HTML_FILE qq| $httpSample->{assertionResult}->[0]->{error}->[0]\n|;
print HTML_FILE qq| $httpSample->{assertionResult}->[0]->{failureMessage}->[0]\n\n|;
}
print HTML_FILE <<"EOF";
$value | $failure | $failureMessage |
EOF
return;
}
print HTML_FILE "
";
close (HTML_FILE);