Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I forgot to mention in my question that if the number of violations for a function was greater than 20, I only wanted the first 20 descriptions as FunctionReasons. I added the first four lines and the last line outside of the sax parsing. I get the output in another module by calling the last property 'Get XMLDoc_Function()'. Here is what I got;</p> <pre><code>Option Explicit Implements IVBSAXContentHandler Dim m_oContentHandler As IVBSAXContentHandler Dim m_wtr_Function As MXXMLWriter40 Dim m_oAttributes As MSXML2.SAXAttributes Dim m_DOM As MSXML2.DOMDocument40 Dim m_sAttribute As String Dim m_sFunctionName As String Dim m_sFunctionDescription As String Dim m_sFunctionReason As String Dim m_sFunctionReasonCount As Integer Dim isDescription As Boolean Private Sub Class_Initialize() Set m_wtr_Function = New MXXMLWriter40 m_wtr_Function.omitXMLDeclaration = True Set m_oContentHandler = m_wtr_Function Set m_DOM = New MSXML2.DOMDocument40 m_DOM.setProperty "SelectionLanguage", "XPath" m_sFunctionReasonCount = 0 End Sub Private Sub Class_Terminate() Set m_wtr_Function = Nothing Set m_oContentHandler = Nothing Set m_oAttributes = Nothing Set m_DOM = Nothing End Sub Private Sub IVBSAXContentHandler_characters(strChars As String) If isDescription Then If m_sFunctionReasonCount &lt; 20 Then m_sFunctionReason = ", FunctionReason: " &amp; strChars m_sAttribute = m_sAttribute &amp; m_sFunctionReason m_sFunctionReasonCount = m_sFunctionReasonCount + 1 isDescription = False End If End If End Sub Private Property Set IVBSAXContentHandler_documentLocator(ByVal RHS As MSXML2.IVBSAXLocator) End Property Private Sub IVBSAXContentHandler_endDocument() End Sub Private Sub IVBSAXContentHandler_endElement(strNamespaceURI As String, strLocalName As String, strQName As String) Select Case strQName Case "function" m_oAttributes.addAttribute "", "desc", "desc", "xs:string", m_sAttribute m_oContentHandler.startElement strNamespaceURI, "error", "error", m_oAttributes m_oContentHandler.endElement strNamespaceURI, "error", "error" m_sAttribute = "" m_sFunctionReasonCount = 0 End Select 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 Sub IVBSAXContentHandler_startDocument() m_oContentHandler.startDocument End Sub Private Sub IVBSAXContentHandler_startElement(strNamespaceURI As String, strLocalName As String, strQName As String, ByVal oAttributes As MSXML2.IVBSAXAttributes) Select Case strQName Case "functions" 'do nothing Case "function" Set m_oAttributes = New SAXAttributes40 m_sFunctionName = oAttributes.getValueFromQName("name") m_sAttribute = "FunctionName: " &amp; m_sFunctionName m_sFunctionDescription = oAttributes.getValueFromQName("Description") m_sAttribute = m_sAttribute &amp; ", FunctionDescription: " &amp; m_sFunctionDescription Case "description" isDescription = True End Select End Sub Private Sub IVBSAXContentHandler_startPrefixMapping(strPrefix As String, strURI As String) End Sub Public Property Get XMLDoc_Function() As Variant XMLDoc_Function = m_wtr_Function.output End Property </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload