Examples: Document property (NotesDOMParser - LotusScript)

This agent parses the origXML file and writes information about the root document to outputFile.

Sub Initialize
  Dim session As NotesSession
  Dim db As NotesDatabase
  Dim inputStream As NotesStream, outputStream As NotesStream
  Dim domParser As NotesDOMParser
  
  Dim origXML As String, outputFile As String
  origXML = "c:\dxl\xmldom.xml"
  outputFile = "c:\dxl\DOM1.txt"
  
  Dim message As String
  Dim passDescription As String, failDescription As String
  passDescription = "Root document identified"
  failDescription = "Root document is null"
  
  On Error Goto errh
  
  Set session = New NotesSession
  Set db = session.CurrentDatabase
  
  'create the output file
  Set outputStream =session.CreateStream
  outputStream.Open (outputFile)
  outputStream.Truncate
  
  'open the XML file
  Set inputStream = session.CreateStream
  inputStream.Open (origXML)
  If inputStream.Bytes = 0 Then
    message = origXML+" is empty"
    Goto results
  End If
  
  'create DOM parser and process
  Set domParser=session.CreateDOMParser(inputStream, outputStream)
  domParser.Process
  
  If Not domParser.Document.IsNull  Then 
    message = passDescription
  Else
    message = failDescription
  End If
results:
  outputStream.WriteText (message)
  Call outputStream.Close
  Exit Sub
errh:
  outputStream.Write (Cstr(Err)+":  "+Error+Chr(13))
  Resume results
End Sub