use warnings;
use strict;
use XML::Twig;
my $xml=<<'XML';
<root>
<ProductKey>99</ProductKey>
<Volume VolumeCategory="L" MeasurementCategory="Real">0.063</Volume>
<Volume VolumeCategory="L" MeasurementCategory="Real">0.098989</Volume
+>
<Volume VolumeCategory="cuft" MeasurementCategory="Real">2.2</Volume>
</root>
XML
my @vol_cat_L;
my $twig= new XML::Twig(
twig_handlers => { '/root/Volume[@VolumeCate
+gory="L"]' => sub {push @vol_cat_L, $_},
},
);
$twig->parse( $xml);
print "Number of L volume category: ",scalar @vol_cat_L,"\n";
##OUTPUT (note the line in example data added by me):
Number of L volume category: 2
HtH L*
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
|