in reply to reading multiple xmls in a folder and to get tagvalues stored and then printed to HTML
The following works with your xml (you have two </testResults> tags in your xml; there should be only one):
use XML::Simple qw(:strict); my $xmlFile = 'textResults.xml'; my $xmlDocument = XMLin($xmlFile, ForceArray => 1, KeyAttr => {}, ); foreach my $httpSample (@{$xmlDocument->{httpSample}}) { print qq|<failure>$httpSample->{assertionResult}->[0]->{failure}-> +[0]</failure>\n|; print qq|<error>$httpSample->{assertionResult}->[0]->{error}->[0]< +/error>\n|; print qq|<failureMessage>$httpSample->{assertionResult}->[0]->{fai +lureMessage}->[0]</failureMessage>\n\n|; }
Running this generates the following:
<failure>true</failure> <error>false</error> <failureMessage>Test failed: text expected to contain /Login/</failure +Message> <failure>true</failure> <error>false</error> <failureMessage>Test failed: code expected to contain /200/</failureMe +ssage> <failure>true</failure> <error>false</error> <failureMessage>Test failed: text expected to contain /true/</failureM +essage> ...
Add the code to process each file.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: reading multiple xmls in a folder and to get tagvalues stored and then printed to HTML
by numberuno (Initiate) on Apr 27, 2012 at 08:15 UTC | |
by Anonymous Monk on Apr 27, 2012 at 12:11 UTC |