use warnings; use strict; use Mojo::DOM; my $xml = <<'ENDXML'; 3 14 159 ENDXML my $dom = Mojo::DOM->new->xml(1)->parse($xml); my $i = 1; $dom->find('foo')->each(sub{ $_->content($i++) }); print $dom->to_string; __END__ 1 2 3