#!/usr/bin/perl use strict; use warnings; use Test::More tests => 1; use XML::Twig; my $doc=' Some text here which may be any length and contain a number of child tags.'; my $expected= ' Some text here which may be any length and contain a number of child tags.'; my $t=XML::Twig->new->parse( $doc); $t->root->mark( qr/(may|child)/, 'bold'); is( $t->sprint, $expected, 'simple replace');