Examples: CreateDXLImporter method

This agent imports DXL from a file into a newly created database.

Sub Initialize
  Dim session As New NotesSession
  Dim db As NotesDatabase
  Set db = session.CurrentDatabase
  filename$ = Left(db.FileName, Len(db.FileName) - 4)
  
  REM Open xml file named after current database
  Dim stream As NotesStream
  Set stream = session.CreateStream
  If Not stream.Open("c:\dxl\" & filename$ & ".xml") Then
    Messagebox "Cannot open " & filename$,, "Error"
    Exit Sub
  End If
  If stream.Bytes = 0 Then
    Messagebox "File did not exist or was empty",, filename$
    Exit Sub
  End If
  
  REM Create new database named after current database
  Dim dbCopy As NotesDatabase
  Set dbCopy = New NotesDatabase("", "")
  Call dbCopy.Create("", filename$ & "Copy", True)
  
  REM Import DXL into new database
  Dim importer As NotesDXLImporter
  Set importer = session.CreateDXLImporter(stream, dbCopy)
  Call importer.Process
End Sub