#!/usr/bin/env perl use warnings; use strict; use XML::Twig; XML::Twig->new( keep_spaces => 1, twig_print_outside_roots => 1, twig_roots => { tu => sub { my ($twig, $elt) = @_; $elt->set_att('creationid','Simon Simonsen'); $elt->print; } }, )->parsefile('1097276.xml');