As per MSXML 4.0 documentation:
The IMXReaderControl interface, which provides the ability to abort, suspend, and resume SAX parsing operations, was implemented for earlier technology preview releases. However, this interface was deemed unready for inclusion in the final release of MSXML 4.0. It has been removed until further notice.
So, if you are using SAXXMLReader40 in your MSXML SAX application, you'll not be able to make use of SAX parsing abort feature. The workaround is to use SAXXMLReader30.
Click here to download a Visual Basic sample application that illustrates using SAXXMLReader30 from the MSXML 4.0 library (as the project adds reference to MSXML 4.0 type library) to abort SAX parsing. Make sure to copy included broadband.xml onto your c:\.
Here is the partial code from the class that implements IVBSAXContentHandler
Implements IVBSAXContentHandler
Public ReaderCtrl As IMXReaderControl
Private Sub IVBSAXContentHandler_startElement(strNamespaceURI As String _
, strLocalName As String, strQName As String _
, ByVal oAttributes As MSXML2.IVBSAXAttributes)
If strQName = "Provider" Then
RateVal = oAttributes.getValueFromQName("Rate")
NameVal = oAttributes.getValueFromQName("Name")
If CInt(RateVal) < 49 Then
MsgBox "Found! " & NameVal & " ($" & RateVal & ")"
ReaderCtrl.abort
Else
Debug.Print "Ignoring " & NameVal & " ($" & RateVal & ")"
End If
End If
End Sub And here is the main application code that uses above class for parsing: (note we are using SAXXMLReader30 instead of SAXXMLReader40, even though the application adds reference to MSXML 4.0):
Private Sub Form_Load()
Dim ReaderObj As New SAXXMLReader30
Dim CHImplObj As New ContentHandlerImpl
'Register the Content Handler
Set ReaderObj.contentHandler = CHImplObj
'Initialize the IMXReaderControl object
Set CHImplObj.ReaderCtrl = ReaderObj
'Start the parsing
ReaderObj.parseURL "C:\broadband.xml"
'End the application
Unload Me
End Sub
Click here for a C++ example.
|