Validate an XML Document or Fragment (Visual Basic)
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: validateDOM.frm | 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 Visual Basic Project
- Create a Visual Basic project and set a reference to MSXML 5.0. For detailed instructions on how to do this, see Set Up My Visual Basic Project.
- Name the project validateDOMProj.
Next, we'll add the source code for this project.