Validate XML Schema with msxml parser

I want to check the XML file for the XML Schema file. This is a simple XML file, does not include namespace, etc. I want to do this in C ++ using MSXML 6.0.

+3
source share
1 answer

You can check how you download. This is sample code from the Windows / MSXML SDK:

   IXMLDOMSchemaCollectionPtr   pXS;
   IXMLDOMDocument2Ptr          pXD = NULL;
   IXMLDOMParseErrorPtr         pErr = NULL;
   _bstr_t                      strResult = "";

   HRESULT hr = pXS.CreateInstance(__uuidof(XMLSchemaCache50));
   hr = pXS->add("urn:namespace", "myschema.xsd");

   // Create a DOMDocument and set its properties.
   hr = pXD.CreateInstance(__uuidof(DOMDocument50));

   // 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");

   // check hr and pXD->errorCode here

You can download the MSXML6 SDK to get this sample and many more. Note. It will not be installed on Vista. If you run Vista, you will get the Windows SDK .

+3
source

Source: https://habr.com/ru/post/1711340/


All Articles