VERSION 1.0 CLASS BEGIN MultiUse = -1 'True END Attribute VB_Name = "XML_SaxDocument" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = False Attribute VB_Exposed = False Option Explicit ' This class implements the MSXML IVBSAXContentHandler interface Implements IVBSAXContentHandler ' This string will be used for the Full Document's output Dim msg As String Dim dicOutput As Scripting.Dictionary ' This string will be used to collect character data (as it may not be all in one piece) Dim buffer As String ' This method allows the calling VB form to retrieve this Handler 's output Public Function GetOutput() As String GetOutput = msg End Function 'this method allows the calling form to retrieve a copy of the Project Dictionary Object Public Function GetProjectResults() As Scripting.Dictionary Set GetProjectResults = dicOutput End Function ' The startElement() method prints out the name of the element followed by a colon Private Sub IVBSAXContentHandler_startElement(strNamespaceURI As String, _ strLocalName As String, strQName As String, ByVal oAttributes As MSXML2.IVBSAXAttributes) msg = msg + strLocalName + ": " Dim lngCnt As Long Dim strProp As String Select Case strLocalName Case "forumstats" For lngCnt = 0 To oAttributes.Length - 1 strProp = strLocalName & oAttributes.getLocalName(lngCnt) If Not dicOutput.Exists(strProp) Then dicOutput.Add strProp, oAttributes.getValue(lngCnt) End If Next lngCnt Case "latest" 'Since Description has text value not attributes we must grab it during the character event If Not dicOutput.Exists(strLocalName) Then dicOutput.Add strLocalName, "" End If End Select End Sub ' The characters() method adds the characters currently being read to the buffer Private Sub IVBSAXContentHandler_characters(strChars As String) buffer = buffer + strChars End Sub ' the endElement() method trims whitespace from the buffer, prints out the contents of the ' buffer followed by a carriage return and line feed, and then clears the buffer Private Sub IVBSAXContentHandler_endElement(strNamespaceURI As String, _ strLocalName As String, strQName As String) buffer = Trim(buffer) msg = msg + buffer + vbCrLf 'if Description then we write the new value to the dictionary object If strLocalName Like "post" Then dicOutput.Item(strLocalName) = buffer End If buffer = "" End Sub Private Sub IVBSAXContentHandler_startDocument() Set dicOutput = New Scripting.Dictionary End Sub ' The rest of the methods are empty and not used by this handler Private Sub IVBSAXContentHandler_endDocument() End Sub Private Sub IVBSAXContentHandler_startPrefixMapping(strPrefix As String, strURI As String) End Sub Private Sub IVBSAXContentHandler_endPrefixMapping(strPrefix As String) End Sub Private Sub IVBSAXContentHandler_ignorableWhitespace(strChars As String) End Sub Private Sub IVBSAXContentHandler_processingInstruction(strTarget As String, strData As String) End Sub Private Sub IVBSAXContentHandler_skippedEntity(strName As String) End Sub Private Property Set IVBSAXContentHandler_documentLocator(ByVal RHS As MSXML2.IVBSAXLocator) End Property