use strict; use warnings; use XML::Twig; my $xmlStr = < Strategy Test1 SubStrategy Test2 XML my $t = XML::Twig->new(); $t->parse($xmlStr); for my $bucket ($t->root()->children('customBucket')) { if ($bucket->first_child('customDimensionName')->text() ne 'Strategy') { print 'customDimensionName ' , $bucket->first_child('customDimensionName' )->text(), "\n"; print 'customBucketValueString ', $bucket->first_child('customBucketValueString')->text(), "\n"; } } __END__ customDimensionName SubStrategy customBucketValueString Test2