Validate an XML Document Against an XML Schema (JScript)
MSXML provides various ways to connect an XML schema to an XML document for the purpose of validating the document contents.
You can use the
xsi:noNamespaceSchemaLocation
attribute to reference the XSD schema file from within the XML document.. For more information, see Example 1: Validating with noNamespaceSchemaLocation.You can also use the
xsi:SchemaLocation
attribute to reference the XSD schema file from within the XML document. For more information, see Example 2: Validating with schemaLocation.You can programmatically add the XSD schema file to an
XMLSchemaCache
object, and then connect the cache to the DOM document or SAX reader, prior to loading or parsing the XML document. For more information, see Example 3: Validating with XMLSchemaCache.You can include the XSD schema directly inline within the XML document itself. For more information, see Example 4: Validating with an Inline XSD Schema.
In this section we will demonstrate and discuss each approach, to help you determine which is right for your application.