CreateXmlWriter (Compact 7)
3/12/2014
This function creates a new IXmlWriter.
Syntax
HRESULT CreateXmlWriter (
REFIID riid,
void** ppvObject,
IMalloc* pMalloc
);
Arguments
- riid
[in] The reference ID
- ppvObject
[out] An out argument that returns the writer
- pMalloc
[in] An IMalloc implementation specified by the user. This argument can be Null.
Return Value
This function returns S_OK if no error is generated.
Remarks
This constructor is used to create the writer. If no IMalloc is provided, the default implementation of IMalloc is used.
The following code shows the declaration of an IXmlWriter object. The declaration and creation of an IStream object; and the call to CreateXmlWriter:
// 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;
}
See Also
Reference
Functions
IXmlWriter
IMalloc
IStream
CreateXmlWriter
Error Codes