I am using MSXML6 to validate some XML files against XSD schemas.
According to this example and this documentation, the IXMLDomDocument has a property called schemas that is supposed to allow me to load an xsd file and associate it with my document.
My problem is that on this line : pXD->schemas = pXS.GetInterfacePtr();
, Visual says that class "MSXML2::IXMLDOMDocument2" has no member "schemas"
Here's what my code looks like :
...
#import <msxml6.dll>
using namespace MSXML2;
...
bool validate_XML_against_XSD(){
...
IXMLDOMSchemaCollectionPtr pXS;
IXMLDOMDocument2Ptr pXD = NULL;
MSXML2::IXMLDOMParseErrorPtr pErr = NULL;
_bstr_t strResult = "";
CComVariant xsd_file;
xsd_file = "path_to_xsd";
BSTR empty_bstr = SysAllocString(L"urn:namespace");
HRESULT hr = pXS.CreateInstance(__uuidof(XMLSchemaCache60));
hr = pXS->add(empty_bstr, xsd_file);
// Create a DOMDocument and set its properties.
hr = pXD.CreateInstance(__uuidof(DOMDocument60));
// Assign the schema cache to the DOMDocument's
// schemas collection.
pXD->schemas = pXS.GetInterfacePtr();
// Load books.xml as the DOM document.
pXD->async = VARIANT_FALSE;
pXD->validateOnParse = VARIANT_TRUE;
pXD->resolveExternals = VARIANT_TRUE;
hr = pXD->load("TheXmlDocument.xml");
...
}
I also got the same error for :
pXD->async = VARIANT_FALSE;
pXD->validateOnParse = VARIANT_TRUE;
pXD->resolveExternals = VARIANT_TRUE;
It says that class "MSXML2::IXMLDOMDocument2" has no member "async"
etc
So, I don't really understand why so much different examples seems to have no problem with this sample of code but I do.
I tried to look for other documentation or stackoverflow posts that would tell me to do an other way but I didn't find any.
Is it a problem of library import or a problem from my code? Anyone has an idea of how to fix this?
Thanks