my $xp = XML::XPath->new( ioref => $input ); my $mp = $xp->find('/meta-parameter'); for my $n ($mp->get_nodelist) { if( $xp->findvalue('@type' => $n) eq "stored-procedure" ) { warn "found: " . $xp->findvalue( '@id' => $n ); } } #### if( m/<([^>]*meta-parameter[^>]*stored-procedure[^>]*)>/ ) { my $tag = $1; if( $tag =~ m/id=['"](.+?)['"]/ ) { my $id = $1; # argueably not the most robust thing in the whole wide world, # but you get the idea } }