Matthias Niggemeier wrote:

Hi there!
I have to write my XML-Doc in a file and in a database.
Since I do not want to read the file back, I searched a bit
and found DOMWriter->writeToString(...)
Unfortunately, this method always returns UTF-16, but my file
is UTF-8 and the entry in the database should be exactly the same as in the file. How can I achieve this?
(Since the program produces a huge number of xml-files every
run, re-reading the file is not an option.)

Regards

Matthias


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Hi Matthias,

I think writeToString _always_ outputs UTF16. Even when you set the document encoding to something else. It says this somewhere, but it's not clear in the docs (xerces v2.4.0) and took me a while to find out, mega frustration !

If you want to output utf-8, iso-8859-1, etc, I believe you have set that encoding in the document (DOM) and then use a format target to get your output.

Something akin to the following :

DOMWriterImpl theWriter;

   XMLFormatTarget *myFormatTarget = new MemBufFormatTarget();

theWriter.writeNode(myFormatTarget, *myDomDoc); // serialize the doc to an internal memory buffer

char* theXMLString = (char*) ((MemBufFormatTarget*)myFormatTarget)->getRawBuffer(); // get the string from the target

I think that should do it. Let us know how you get on, and check the apis for post clean-up calls :)

Regards

Dara




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to