Jesse Pelton wrote:
I think theSerializer->writeNode(&outputfile, *doc);
should be
    theSerializer->writeNode(&file, *doc);

Also, note that "outputfile" is a string holding the name of the file to
be written.
That's what happen when you type inside an e-mail client without compiling the code...
Thanks Jesse for the correction

Alberto
-----Original Message-----
From: Alberto Massari [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 12, 2007 2:23 AM
To: [email protected]
Subject: Re: Writing XML to File

neerav patel wrote:
Hi,

I am new at Xerces and I am developing code in Visual C++ .NET 7.1,
not
managed code, just regular C++.

I have managed to write an application that takes the sample
CreateDOMDocument and I want to save that to a file now.  I tried
looking at
DOMPrint example but nothing is making sense.  Can someone give me
some
sample code to take an XML file in memory and write to a file.

This is the minimum amount of code you need:

DOMImplementation *impl = DOMImplementationRegistry::getDOMImplementation(L"LS"); DOMWriter *theSerializer = ((DOMImplementationLS*)impl)->createDOMWriter();
    LocalFileFormatTarget file(outputfile);
    theSerializer->writeNode(&outputfile, *doc);
    theSerializer->release();

Common options that you may want to specify are a specific encoding (theSerializer->setEncoding(L"ISO-8859-1")) ), and whether the file should be indented (theSerializer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true) ).

Alberto






Reply via email to