There's some stuff in here that you have to change/remove but this is basically what you want to do.

VB Code:
  1. Public Sub ValidateXML()
  2. '***************************************************************************
  3. 'Purpose: Validate the modified xml file against the schema
  4. 'Inputs:  None
  5. 'Outputs: True if OK, False if not.
  6. '***************************************************************************
  7.  
  8.     Dim oxmlSchema As MSXML2.XMLSchemaCache40
  9.     Dim oxmlValidateDoc As MSXML2.DOMDocument40
  10.     Dim strText As String
  11.     Dim intIndex As Integer
  12.    
  13.     Screen.MousePointer = vbHourglass
  14.    
  15.     On Error GoTo ErrorRoutine
  16.    
  17.     'Create the schema cache and add the schema to it.
  18.     Set oxmlSchema = New MSXML2.XMLSchemaCache40
  19.     oxmlSchema.Add "", frmFileLoc.SchemaLocation & "\" & gstrSchemaName
  20.    
  21.     'Create an XML DOMDocument object.
  22.     Set oxmlValidateDoc = New MSXML2.DOMDocument40
  23.    
  24.     'Assign the schema cache to the schemas collection.
  25.     Set oxmlValidateDoc.schemas = oxmlSchema
  26.    
  27.     oxmlValidateDoc.async = False
  28.     'Load the xml file as the DOM document.
  29.     oxmlValidateDoc.Load MyXML_Filename
  30.    
  31.     Screen.MousePointer = vbNormal
  32.    
  33.     'Return validation results in message to the user.
  34.     If oxmlValidateDoc.parseError.errorCode <> 0 Then
  35.         If oxmlValidateDoc.parseError.errorCode = -2146697210 Then
  36.             Err.Raise 1004
  37.         Else
  38.             ' Remove tabs from the text
  39.             strText = Replace(oxmlValidateDoc.parseError.srcText, Chr$(9), "")
  40.             frmValidate.lblResults.Alignment = vbLeftJustify
  41.             frmValidate.lblResults.Caption = _
  42.                     "Error: " & oxmlValidateDoc.parseError.reason _
  43.                     & vbCrLf _
  44.                     & "Found in line number " & oxmlValidateDoc.parseError.Line _
  45.                     & "  line position " & oxmlValidateDoc.parseError.linepos & "." _
  46.                     & vbCrLf & vbCrLf _
  47.                     & strText _
  48.                     & vbCrLf & vbCrLf _
  49.                     & "(Other errors may be present.)"
  50.             frmValidate.imgSad.Visible = True
  51.             frmValidate.imgHappy.Visible = False
  52.             frmValidate.Show vbModal
  53.             frmMain.sbarStatus.Panels(1).Text = "Knowledge base validation failed"
  54.         End If
  55.     Else
  56.         frmValidate.lblResults.Alignment = vbCenter
  57.         frmValidate.lblResults.Caption = vbCrLf & vbCrLf _
  58.                                        & "Knowledge base validation passed"
  59.         frmValidate.imgSad.Visible = False
  60.         frmValidate.imgHappy.Visible = True
  61.         frmValidate.Show vbModal
  62.         frmMain.sbarStatus.Panels(1).Text = "Knowledge base validation passed"
  63.     End If
  64.    
  65.     Set oxmlSchema = Nothing
  66.     Set oxmlValidateDoc = Nothing
  67.  
  68.     Exit Sub
  69.    
  70. ErrorRoutine:
  71.  
  72.     If Err.Number = 1004 Then
  73.         MsgBox ResolveResString(resMissingTempFile), _
  74.                vbExclamation + vbOKOnly, _
  75.                ResolveResString(resErrorTitle, "|1", "Validation")
  76.     Else
  77.         DisplayError "ValidateXML"
  78.     End If
  79.    
  80. End Sub