也许尝试使用该#import
声明.
我在一个VS6项目中使用过它,我做了类似的事情(仅用于说明目的;这对我有用,但我并不认为是错误证明):
#import "msxml6.dll" ... MSXML2::IXMLDOMDocument2Ptr pdoc; HRESULT hr = pdoc.CreateInstance(__uuidof(MSXML2::DOMDocument60)); if (!SUCCEEDED(hr)) return hr; MSXML2::IXMLDOMDocument2Ptr pschema; HRESULT hr = pschema.CreateInstance(__uuidof(MSXML2::DOMDocument60)); if (!SUCCEEDED(hr)) return hr; pschema->async=VARIANT_FALSE; VARIANT_BOOL b; b = pschema->loadXML(_bstr_t( /* your schema XML here */ )); MSXML2::IXMLDOMSchemaCollection2Ptr pSchemaCache; hr = pSchemaCache.CreateInstance(__uuidof(MSXML2::XMLSchemaCache60)); if (!SUCCEEDED(hr)) return hr; _variant_t vp=pschema.GetInterfacePtr(); pSchemaCache->add(_bstr_t( /* your namespace here */ ),vp); pdoc->async=VARIANT_FALSE; pdoc->schemas = pSchemaCache.GetInterfacePtr(); pdoc->validateOnParse=VARIANT_TRUE; if (how == e_filename) b = pdoc->load(v); else b = pdoc->loadXML(bxmldoc); pXMLError = pdoc->parseError; if (pXMLError->errorCode != 0) return E_FAIL; // an unhelpful return code, sigh....