ramya2005 has asked for the wisdom of the Perl Monks concerning the following question:

Dear Perl Monks,

I am using XML::Twig to parse an XML file. At the end of parsing/editing the XML string is stored as a scalar. I want to generate/save a new xml file. Is there any in-built function in XML::Twig which create the XML file using the content of the scalar?
Any pointers will be much appreciated!
$Tree = new XML::Twig(); $Tree -> parsefile($TemplateName); $Tree -> print;

Replies are listed 'Best First'.
Re: Save XML::Twig tree into *.xml file
by davidrw (Prior) on Aug 17, 2005 at 19:34 UTC
    looking at XML::Twig POD, the print ($optional_filehandle, %options) method can take a filehandle.. so this should work:
    $captureTemplateTree = new XML::Twig(); $captureTemplateTree->parsefile($captureTemplateName); open my $fh, "/tmp/out.xml"; $captureTemplateTree->print( $fh );
      Thanks for your input!
      This works!
        But, we need to manually reload the document ? How can we save the document and reload the document as my application is still running.