Microsoft XML Core Services (MSXML) 4.0 - SAX2 Developer's Guide

Implementing the ErrorHandler (Visual Basic)

For the JumpStart application, you create the ErrorHandler by implementing the IVBSAXErrorHandler interface.

To create the ErrorHandlerImpl class

  1. On the Project menu, click Add Class Module.
  2. In the Add Class Module dialog box, double-click Class Module.
  3. On the View menu, select Properties Window.
  4. In the Properties Window, enter "ErrorHandlerImpl" for the Name property.

To implement the ErrorHandlerImpl class

  1. In the Class Window, type "Implements", press the spacebar, and then double-click IVBSAXErrorHandler from the drop-down list that appears.
  2. In the Object drop-down list on the left side of the Class Window, select IVBSAXErrorHandler.
  3. In the Procedure drop-down list on the right side of the Class Window, select a method or property to add to the class.
  4. Add the desired code to the selected method or property.
  5. Repeat steps 3 and 4 until you have added the desired methods and properties.
    Note   If you have trouble implementing methods and procedures for the ErrorHandlerImpl class, refer back to Implementing the ContentHandler to see how methods and properties were implemented for the ContentHandlerImpl class.

Complete Code for the ErrorHandlerImpl Class

The following is the complete code for the ErrorHandlerImpl class of the JumpStart application.

Option Explicit
Implements IVBSAXErrorHandler

Private Sub IVBSAXErrorHandler_fatalError(ByVal lctr As IVBSAXLocator, _
                                   msg As String, ByVal errCode As Long)

  frmMain.rtfOutput.Text = frmMain.rtfOutput.Text & "*** error *** " & msg

End Sub

Private Sub IVBSAXErrorHandler_error(ByVal lctr As IVBSAXLocator, msg As _
                                           String, ByVal errCode As Long)
    
End Sub

Private Sub IVBSAXErrorHandler_ignorableWarning(ByVal oLocator As _
                       MSXML2.IVBSAXLocator, strErrorMessage As String, _
                       ByVal nErrorCode As Long)
    
End Sub

In the preceding code, only the fatalError method contains code for handling events. For this version of Microsoft® XML Core Services (MSXML), only the fatalError method is called for IVBSAXErrorHandler.

See Also

Sample XML File (books.xml) | Overview of the JumpStart Application | Implementing the ContentHandler | Implementing the DTDHandler | Creating the Main Form

This HTML Help has been published using the chm2web software.