# if you don't care where in the structure is the tag, this would be sufficient: use strict; use warnings; use XML::Rules; my $parser = XML::Rules->new( namespaces => { 'http://schemas.xmlsoap.org/soap/envelope/' => 'soap', 'http://com/Server' => 'srv', 'http://com' => 'com' }, rules => { 'srv:MaxCode' => sub { my ($attrs, $parser) = @_[1,4]; $parser->return_this($attrs->{_content}); } } ); my $content = qq| {7f000001-47db2420000001569783cdb88136} soap:Server check expression: CheckTwo Exception occurred -2225 |; my $result = $parser->parse($content); print $result;