MXXMLWriter

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Anyone know how to stream MXXMLWriter to a file? No matter what I try I end up with an empty file. My last attempt

MSXML2::IMXWriterPtr pWriter
hr = pWriter.CreateInstance(__uuidof(MSXML2::MXXMLWriter40))
_ASSERT(SUCCEEDED(hr))

ISAXContentHandlerPtr pContentHandler
pContentHandler = pWriter

ofstream m_pFileStream;
m_pFileStream.open( outFile, ios::out )

pWriter->put_output( _variant_t(m_pFileStream) )

hr = pContentHandler->startDocument()

<write some xml

hr = pContentHandler->endDocument()

m_pFileStream.close()
 
kg said:
Anyone know how to stream MXXMLWriter to a file? No matter what I try I
end up with an empty file. My last attempt:
MSXML2::IMXWriterPtr pWriter;
hr = pWriter.CreateInstance(__uuidof(MSXML2::MXXMLWriter40));
_ASSERT(SUCCEEDED(hr));

ISAXContentHandlerPtr pContentHandler;
pContentHandler = pWriter;

ofstream m_pFileStream;
m_pFileStream.open( outFile, ios::out );

pWriter->put_output( _variant_t(m_pFileStream) );

Hi, I doubt that ofstream supports the IStream interface. That is required
for IMXWriter. Also, check the return value when you set the stream, to find
mistakes like this one in the future.
For an implementation for a file stream of the right kind, look here:
http://www.xml.com/lpt/a/2002/03/06/efficient.html

Regards, Andreas
 
Back
Top