#!/usr/bin/perl -w use strict; use XML::Twig; my $t1 = XML::Twig::Elt->new("foo", { bar => 'baz' }); my $t2 = XML::Twig::Elt->new("bar", { fizz => 'bang' }, "wow"); $t2->paste('last_child', $t1); print $t1->sprint(), "\n";