in reply to XML::XPath printToFile function?

According to the docs for XML::XPath::Node::Element, there is no such method. You could do it yourself, however:
open (FH,'>filename.xml') or die $!; print FH $root->toString; close FH;

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)