Validate an XML Document or Fragment (Smart)
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 the following files.
Component | Description |
---|---|
Source: validateDOMsmart.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 validateDOMsmart project, you should get this output in a console window. |
Create the validateDOMsmart 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 validateDOMsmartProj.
Next, we'll add the source code for the validateDOMsmart project.