I don't know about your compiler, but I just did the same thing for MSVC
6.0:
Declare a ostrstream (string out stream) instance:
ostrstream XMLSourceStream;
Add a ostream* member to DOMPrintFormatTarget:
ostream* DOMPrintFormatTarget::pTarget;
Modify the DOMPrintFormatTarget to accept a pointer to a iostream and save
this in DOMPrintFormatTarget::pTarget:
DOMPrintFormatTarget( ostream* pStream ) { pTarget = pStream; }
Now do all writing in DOMPrintFormatTarget to pTarget instead of cout.
The same inside the examples main function so for example instead of:
cout << doc;
You do:
XMLSourceStream << doc;
Once you're done you can retrieve the XML source from the buffer:
CString XMLSourceString = XMLSourceStream.str();
// Calling str() causes buffer to freeze, so unfreeze to allow for buffer
destruction
XMLSourceStream.rdbuf()->freeze( 0 );
There are some small details to fix as well but this is the main idea. You
can also just redirect cout and cerr to self declared ostream or ostrstream
objects. That saves you modifying the cout << statements, but it wouldn't be
threadsafe. Also, I did this for Windows/MSVC 6.0 but I'm sure you can do
something similar on your platform.
Gert van Spijker
> hi everybody
> i am a new user i xerces c for linux.
> i have 2 questions :
> 1/how can I convert an XML document to char*:example , can I convert the
DOM_Document (doc) obtainted in the sample
> CREATEDOMDOCUMENT to char*.
> 2/how can I write in a file or view on the screen this document.
> thanks all
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]