Пример #1
0
// Helper function to create a DOM instance:
MSXML2::IXMLDOMDocument * DomFromCOM()
{
    HRESULT hr;
    MSXML2::IXMLDOMDocument *pxmldoc = NULL;

    HRCALL( CoCreateInstance(__uuidof(DOMDocument),
                             NULL,
                             CLSCTX_INPROC_SERVER,
                             __uuidof(MSXML2::IXMLDOMDocument),
                             (void**)&pxmldoc),
            "Create a new DOMDocument");

    HRCALL( pxmldoc->put_async(VARIANT_FALSE),
            "should never fail");
    HRCALL( pxmldoc->put_validateOnParse(VARIANT_FALSE),
            "should never fail");
    HRCALL( pxmldoc->put_resolveExternals(VARIANT_FALSE),
            "should never fail");

    return pxmldoc;
clean:
    if (pxmldoc)
    {
        pxmldoc->Release();
    }
    return NULL;
}
/* Helper function to create a DOM instance. */
MSXML2::IXMLDOMDocument *NXMLSettings::DomFromCOM()
{
	HRESULT					hr;
	MSXML2::IXMLDOMDocument	*pxmldoc = NULL;

	hr = CoCreateInstance(__uuidof(MSXML2::DOMDocument30),NULL,CLSCTX_INPROC_SERVER,
		__uuidof(MSXML2::IXMLDOMDocument),reinterpret_cast<LPVOID *>(&pxmldoc));

	if(SUCCEEDED(hr))
	{
		pxmldoc->put_async(VARIANT_FALSE);
		pxmldoc->put_validateOnParse(VARIANT_FALSE);
		pxmldoc->put_resolveExternals(VARIANT_FALSE);
		pxmldoc->put_preserveWhiteSpace(VARIANT_TRUE);
	}

	return pxmldoc;
}