To get started, create a new project and then reference Microsoft XML Core Services (MSXML) 5.0 for Microsoft Office.
To create a new project
To create a reference to MSXML 5.0
Now you must build the user interface for the simple filter application. Add the following controls to the form.
The form should look like the following.
The code for the form:
MXXMLWriter
and SAXAttributes
objects.SAXXMLReader
.ContentHandlerImpl
class implementing the IVBSAXContentHandler
and IVBSAXErrorHandler
interfaces.errorHandler
and the contentHandler
properties for the SAXXMLReader
to point to the ContentHandlerImpl
class.MXXMLWriter
to variables in the ContentHandlerImpl
class that hold references to the IVBSAXContentHandler
and IVBSAXErrorHandler
interfaces. This enables the MXXMLWriter
object to receive ContentHandler
and ErrorHandler
events.SetFilterCriteria
method in the ContentHandlerImpl
class and sets the filter criteria.'Create a writer and an attribute helper. Public oWriter As New MXXMLWriter50 Public atrs As New SAXAttributes50 Private Sub Command1_Click() 'Create the reader. Dim rdr As New SAXXMLReader50 'Create the content handler. Dim cnth As New ContentHandlerImpl 'Set the content handler for the reader. Set rdr.contentHandler = cnth 'Set the error handler for the reader. Set rdr.errorHandler = cnth 'Set the writer for the content handler. Set cnth.oContentHandler = oWriter 'Set the error handler for the writer. Set cnth.oErrorHandler = oWriter 'Configure output for the writer. oWriter.indent = True oWriter.standalone = True oWriter.output = "" oWriter.omitXMLDeclaration = True 'Set the filter criteria in the content handler. cnth.SetFilterCriteria (Text3.Text) On Error GoTo HandleError 'Parse the document. rdr.parseURL (Text2.Text) Text1.Text = oWriter.output Exit Sub HandleError: If Not cnth.errorHappen Then Text1.Text = "**** Error **** " & Err.Number & " : " & Err.Description End If End Sub Private Sub Command2_Click() Unload Me End Sub
How Filter Criteria is Set | IMXWriter Interface | MXXMLWriter CoClass | ISAXContentHandler Interface | ISAXErrorHandler Interface