http://qs321.pair.com?node_id=752469


in reply to Twig Question: Create a new XML doc using twig?

Unless I'm missing the point, all you need to do is add the filehandle reference to your print statement.
$root->print($file_handle);
To print to two files, do this with two filehandles.

Update:Removed quotes per GrandFather's comments. My apologies on the typo.