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