Your program looks like an unfinished thought :) you never setup the xml parser ...

JMeter docs hint it comes with a mailer and xsl for fomatting report http://svn.apache.org/viewvc/jmeter/trunk/extras/jmeter-results-report.xsl?view=markup, but if you insist on perl, use XML::Twig; # its pure-perl built on top of XML::Parser

Write it like this, use autodie for automagic error checking

#!/usr/bin/perl -- use strict; use warnings; use autodie; use XML::Twig; Main( @ARGV ); exit( 0 ); sub Main { parseJmeter( \*DATA, \*STDOUT ); # DEMO } sub parseJmeter { my( $inFilenameOrHandle, $outHandle ) = @_; my( $error, $value, $failure, $failureMessage ) = ("") x 4; # INIT + TO EMPTY my $t = XML::Twig->new( twig_handlers => { 'failure' => sub { warn $_->path; $failure = $_->text; }, 'failureMessage' => sub { warn $_->path; $failureMessage = $_->text; }, 'error' => sub { warn $_->path; $error = $_->text; }, '/*/*//httpSample' => sub { warn $_->path; ## children $value .= $_->att('lb') . "\n"; }, '/*/httpSample' => sub { # TRIGGERED LAST, the daddy httpSampl +e warn 'YO ', $_->path; $value .= $_->att('lb') . "\n"; ## append print $outHandle qq{ <tr><td><p> $value </p> <td><p> $failure </p></td> <td><p> $failureMessage </p></td></tr> }; ( $error, $value, $failure, $failureMessage ) = ("") x 4; + # RESET TO EMPTY }, }, ); $t->xparse( $inFilenameOrHandle ); $t->purge; return; } __END__ <?xml version="1.0" encoding="UTF-8"?> <testResults version="1.2"> -- HTTP Sample, with nested samples <httpSample t="1392" lt="351" ts="1144371014619" s="true" lb="HTTP Request" rc="200" rm="OK" tn="Listen 1-1" dt="text" de="iso-8859-1" by="12407"> <httpSample t="170" lt="170" ts="1144371015471" s="true" lb="http://www.apache.org/style/style.css" rc="200" rm="OK" tn="Listen 1-1" dt="text" de="ISO-8859-1" by="1002"> <responseHeader class="java.lang.String"></responseHeader> <requestHeader class="java.lang.String">MyHeader: MyValue</request +Header> <responseData class="java.lang.String"></responseData> </httpSample> <httpSample t="200" lt="180" ts="1144371015641" s="true" lb="http://www.apache.org/images/asf_logo_wide.gif" rc="200" rm="OK" tn="Listen 1-1" dt="bin" de="ISO-8859-1" by="586 +6"> <responseHeader class="java.lang.String"></responseHeader> </httpSample> <responseHeader class="java.lang.String"></responseHeader> <requestHeader class="java.lang.String">MyHeader: MyValue</requestHe +ader> <responseData class="java.lang.String"></responseData> <cookies class="java.lang.String"></cookies> <method class="java.lang.String">GET</method> <queryString class="java.lang.String"></queryString> <url>http://www.apache.org/</url> </httpSample> </testResults>

Since http://search.cpan.org/perldoc/XML::Twig#text doesn't return encoded data, you should look into using http://search.cpan.org/perldoc/XML::Twig#html_encode

I also recommend perlintro, http://learn.perl.org/books/beginning-perl/, http://perl-tutorial.org/, Modern Perl


In reply to Re: trouble,, need help! (parsing apache jmeter xml, preparing html report) by Anonymous Monk
in thread trouble,, need help! by numberuno

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.