or download this
#Open and parse XML
open (my $input, "<xmlsample.xml")or die "Could not open xml input.";
...
open (my $OutputXML, ">xmlsample.xml") or die "Could not write XML fil
+e.";
print $OutputXML $pdoc->toString();
close ($OutputXML) or die "Could not close written XML file.";