You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by Adam Klobukowski <ad...@gmail.com> on 2007/08/10 20:29:09 UTC
Problem with writing to a file
Hello
I have problem with writing to the file. My code looks like this:
(at this moment doc is already existing DOMDocument object with nodes
and stuff)
DOMImplementation *impl =
DOMImplementationRegistry::getDOMImplementation(gLS);
DOMWriter *theSerializer =
((DOMImplementationLS*)impl)->createDOMWriter();
theSerializer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
theSerializer->setEncoding (XMLString::transcode("UTF-8"));
XMLFormatTarget * myFormTarget;
myFormTarget = new LocalFileFormatTarget ("users.xml");
string s = XMLString::transcode (theSerializer->writeToString(*doc));
cout << s << endl;
theSerializer->writeNode(myFormTarget, *doc);
myFormTarget->flush();
theSerializer->release();
As you can see, it is (almost) a copy paste from examples. The problem
is that I see XML document printed correctly on console (cout), but file
on disk (users.xml) has 0 length. ATM. I'm made a hack with fstream, but
writeToString uses UTF-16, and I really need UTF-8.
--
Semper Fidelis
Adam Klobukowski
adamklobukowski@gmail.com