You are viewing a plain text version of this content. The canonical link for it is here.
Posted to p-dev@xerces.apache.org by ravikanth gangarapu <gr...@rediffmail.com> on 2002/04/16 01:29:13 UTC

how to print XML to a file

Hi
   How can I print an XML to a file using 
XML::Xerces::DOMParse::print? it wont accpet filename in a 
string.

thx
grk


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-p-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-p-dev-help@xml.apache.org


RE: how to print XML to a file

Posted by Bjorn Hermans <bj...@e-cube.nl>.
> Hi
>    How can I print an XML to a file using 
> XML::Xerces::DOMParse::print? it wont accpet filename in a 
> string.

You can accomplish this by:
- opening a temporary file (e.g. with the file handle "TEMPFILE";
- then printing the output of the print command to this file:
	XML::Xerces::DOMParse::print(\*TEMPFILE, $doc);
	close TEMPFILE;
- now re-open the temporary file and read the contents into a string;
- delete the temp file.
(This is also a good time to add lines to the XML which are hard to add
to the DOM object, such as an xml version line ("<?xml version='1.0'?>")
and a DOCTYPE line.)
 
Regards,
Bjorn.


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-p-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-p-dev-help@xml.apache.org