469,602 Members | 1,838 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,602 developers. It's quick & easy.

MXXMLWriter

kg
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::MXXMLWrite r40))
_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()

Nov 17 '05 #1
1 2094
"kg" <an*******@discussions.microsoft.com> wrote in message
news:4D**********************************@microsof t.com...
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::MXXMLWrite r40));
_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
Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.