You need one schema and two XML files to validate against the schema.
This program validates the XML document against the schema successfully.
This article explained about the XML document, XSD schema, and how to validate XML document against XSD schema using Microsoft .
Scott Loban demonstrates a method for validating that a dynamic XML document adheres to the rules for document structure and syntax as expressed in a schema.XML is probably the most fundamental of today's core technologies for implementing distributed applications.As part of the validation process, software called a validating parser is used to examine the subject XML, and compare it to these rules.The rules may be specified to the parser, either as a reference to a file (a URI) or by passing the rules as part of the XML documentreferred to as inline.In addition, a valid XML document adheres to an agreed-upon set of rules for document structure, content, syntax, and hierarchical relationships that are domain-specific.
For example, a group of trading partners in the real estate industry might jointly define a set of rules for the representation of property listings in XML.Schema, indicating that we want the Xml Reader to perform validation with a schema as it reads an XML document.Again set the Xml Reader Settings object's Schemas property to schemas.The Validation Error method is called if the document being read is found to be invalid or an error occurs (for example, the document cannot be found).Failure to register a method with Validation Event Handler causes an exception (Xml Exception) to be thrown when the XML document is found to be invalid or missing.However, when the user selects the XML document catalog1.xml, validation fails for the book element in the lines containing more than one title element.