c++ - validate xml schema using msxml parser -


I want to validate the XML file against an 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.

You can validate when you load. This is the sample code from Windows / MSXML SDK:

  IXMLDOMSchemaCollectionPtr pXS; IXMLDOMDocument2Ptr pXD = NULL; IXMLDOMParseErrorPtr pErr = NULL; _bstr_t strResult = ""; HRESULT hr = pxs.CreateInstance (__Uuidof (XMLSchemaCache50)); Hr = px-> Add ("urn: name space", "myschema.xsd"); // Create a DOMDocument and set its properties HR = PXD. Create Instance (__UdOf (Dome Document 50)); Assign // schema cache to the // schema archive of the DOMDocument. PXD- & gt; Schemas = pxs gate interfacePTR (); // Load books.xml as DOM document. PXD- & gt; Async = VARIANT_FALSE; PXD-> Validation = VARIANT_TRUE; PXD- & gt; Halle Extanche = VARIANT_TRUE; Hr = px- & gt; Load ("TheXmlDocument.xml"); // check hour and px- & gt; Error code here  

You can get this sample and many others Note: It will not be installed on Vista. If you run Vista, get it.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -