Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.



Creates a new IXmlWriter or IXmlWriterLite.

HRESULT CreateXmlWriter ([in] REFIID riid, [out] void ** ppvObject, [in] IMalloc * pMalloc);  

The reference ID.

An out argument that returns the writer.

An IMalloc implementation specified by the user. This parameter can be NULL.

Returns S_OK if no error is generated.

This constructor is used to create the writer. If no IMalloc is specified, the default implementation of IMalloc is used.

The following example shows the declaration of an IXmlWriter object; the declaration and creation of an IStream object; and the call to CreateXmlWriter. You can declare pWriter as CComPtr<IXmlWriterLite> instead, and invoke CreateXmlWriter by using IXmlWriterLite to take advantage of its faster output:

// This code is excerpted from XmlLiteNamespaceWriter1.cpp.  
int _tmain(int argc, _TCHAR* argv[])  
    HRESULT hr;  
    CComPtr<IStream> pOutFileStream;  
    CComPtr<IXmlWriter> pWriter;  
    if (argc != 2)  
        printf("Usage: XmlLiteNamespaceWriter1.exe name-of-output-file\n");  
        return 0;  
    //Open writeable output stream  
    if (FAILED(hr = FileStream::OpenFile(argv[1], &pOutFileStream, TRUE)))  
        wprintf(L"Error creating file writer, error is %08.8lx", hr);  
        return -1;  
    if (FAILED(hr = CreateXmlWriter(__uuidof(IXmlWriter),(void**) &pWriter, NULL)))  
        wprintf(L"Error creating xml writer, error is %08.8lx", hr);  
        return -1;  
    if (FAILED(hr = pWriter->SetOutput(pOutFileStream)))  
        wprintf(L"Error setting output for writer, error is %08.8lx", hr);  
        return -1;  

Header: XmlLite.h

Library: XmlLite.lib

IXmlReader Functions

© 2018 Microsoft