Run the Application (SAX Validator)

 

[This sample application uses a feature that was first implemented in MSXML 4.0.]

The following instructions are based on the books.xml and books.xsd files. However, you can use other XML and XSD documents as the files for this application.

To run the application

  1. Build the SAX Validator application.

  2. Make sure that books.xsdandbooks.xml are saved in your application directory.

  3. From the Visual Basic toolbar, click Start.

  4. In the XML file to validate text box, verify that the path for the books.xml file is valid and correct.

  5. In the Use this XSD schema file to validate it text box, verify that the path for the books.xsd file is valid and correct.

  6. On the form, click Validate.

The Results text box should display the following message:

Error: (-2147467259) Element 'review' is unexpected according to content model of parent element 'book'.

Expecting: pub_date.

at line 17, column 14

To get a successful validation result, open books.xml and find the second <book> element. Within this <book> element, add a <pub_date>2001-12-01</pub_date> child element after the <price> child element. Save and close the file, and run the application again. This time, validation should be successful, and the Results text box will display the following message:

File is valid.

See Also

Sample XML File (books.xml)
Sample XML and XSD Files (SAX Validator)
Validate Documents Using SAX
Overview of the SAX Validator Application
Application Form (SAX Validator)
MyValidator Class (SAX Validator)
How the SAX Validator Application Works