Validate an XML Document or Fragment (C/C++)

MSXML 5.0 SDK

Microsoft XML Core Services (MSXML) 5.0 for Microsoft Office - DOM Developer's Guide

Validate an XML Document or Fragment (C/C++)

In MSXML 5.0 and later, there are two ways to validate XML data against a set of XML Schema definitions. One uses the validate method on an XML DOM instance to validate the entire DOM object. The other uses the validateNode(node) method on a DOM instance to validate a DOM fragment. A DOM fragment is a sub-tree rooted at the specified node.

The example in this tutorial illustrates both of these methods. This project uses or creates the following files.

Component Description
Source: validateDOM.cpp Validates an XML file against an XSD schema.
Resource: books.xml and books.xsd An XML data file and an XSD schema file.
Output When you build and run the validateDOM project, you should get this output in a console window.

To create the validateDOM project in Visual C++

  • Create a Win32 console application in Visual C++. For detailed instructions on how to do this, see Set Up My Visual C++ Project. Name the project validateDOMProj.

Next, we'll add the source code for the validateDOM project.