1

Тема: NotesSAXParser

Пробуем с помощью методов класса NotesSAXParser распарсить XML-ку.

Sub Click(Source As Button)
    Dim session As New NotesSession
    Dim db As NotesDatabase
    Set db = session.CurrentDatabase
    
    Dim saxParser As NotesSAXParser
    
    Dim xml_in As NotesStream
    Set xml_in=session.CreateStream
    filename$ = "C:\XML\123.xml"  ' open input file
    xml_in.Open(filename$)
    
    Dim xml_out As NotesStream
    Set xml_out=session.CreateStream
    filename$ = "C:\XML\333.xml" 
    xml_out.Open(filename$)
    
    Set saxParser=session.CreateSAXParser(xml_in, xml_out)
    
    On Event SAX_Characters From saxParser Call SAXCharacters ' содержимое элемента
    On Event SAX_StartElement  From saxParser Call SAXStartElement 'старт элемента
    
    saxParser.Process
End Sub

Две подпрограммы:

Sub SAXCharacters (Source As Notessaxparser, Byval Characters As String, _
Count As Long)
    Source.Output (" Characters: " + Characters)
End Sub
Sub SAXStartElement (Source As Notessaxparser, Byval elementname As String, Attributes As NotesSaxAttributeList)
    Dim i As Integer
    
    Source.Output(" Элемент = "+elementname+"<br>")
    
    If Attributes.Length > 0 Then
        Dim attrname As String
        For i = 1 To Attributes.Length
            attrname = Attributes.GetName(i)
            fype$ = Attributes.GetType (attrname)
            Source.Output(" Атрибут: "+attrname+    " = "+Attributes.GetValue(attrname) +", тип: " +fype$ + "//")
        Next
    End If
End Sub

Поделиться

2

Re: NotesSAXParser

Поделиться