以操作代理为例:
1、在Declarations中声明:%INCLUDE "lsconst.lss"
 将Notes文档导出为XML文件
3、 在Initialize中增加以下代码
Sub Initialize
 'Constants
 Const XML_FILE_FIELD = "XmlDocRenderFile"
 Const XML_OUTPUT_DIR = "c:\notes_xml\"
 Const XML_OUTPUT_ROOT1 = "Rep_"
 Const XML_OUTPUT_ROOT2 = "_Note_"
 Const XML_OUTPUT_SUFFIX = ".xml"
 Const ERR_GENERAL = 1001
 
 'Variables
 Dim Sess As NotesSession
 Dim Stream As NotesStream
 Dim Exporter As NotesDXLExporter
 Dim ThisDb As NotesDatabase
 Dim SelectedDocs As NotesDocumentCollection
 Dim OneDoc As NotesDocument
 Dim XmlFilePath As String, NoteID As String, RepID As String
 Dim HasDir As String
 
 'Set up generic error handler.
 On Error Goto ErrorReturn
 
 'Get a Notes session, which we will use throughout this code.
 Set Sess = New NotesSession
 
     'Get the current database and its replica ID.
 Set ThisDb = Sess.CurrentDatabase
 RepID = ThisDb.ReplicaID
 
 'Get the collection of documents that were selected by the user when this agent is invoked.
 Set SelectedDocs = ThisDb.UnprocessedDocuments
 
 HasDir = Dir$(XML_OUTPUT_DIR,16)
 If HasDir = "" Then
  Mkdir XML_OUTPUT_DIR
 End If
 
 'Create an XML exporter tool.
 Set Exporter = Sess.CreateDxlExporter
 
     'Create an output stream that will receive XML.
 Set Stream = Sess.CreateStream
 
 'Attach the stream as the output of the XML exporter.
 Call Exporter.SetOutput (Stream)
 
 'Create a loop that will process all the selected documents.
 Set OneDoc = SelectedDocs.GetFirstDocument
 While Not OneDoc Is Nothing
 
 
  'Get the Note ID of this document
  NoteID = OneDoc.NoteID
 
  'Make this document the input to the XML exporter.
  Call Exporter.SetInput (OneDoc)
 
  'Create the name of the XML output file.
  Select Case OneDoc.Form(0)
  Case "JWFSETFM02"
   XmlFilePath = XML_OUTPUT_DIR + OneDoc.pwcMWFDesc(0) + "-" + OneDoc.pwcFlowKey(0) + "-" + OneDoc.pwcFlowName(0) + XML_OUTPUT_SUFFIX
  Case Else
   XmlFilePath = XML_OUTPUT_DIR + XML_OUTPUT_ROOT1 + RepID + XML_OUTPUT_ROOT2 + NoteID+ XML_OUTPUT_SUFFIX
  End Select
 
 
  'Associate the XML output stream with the output file.
  Call Stream.Open(XmlFilePath)
 
  'Translate the doc into XML.
  Call Exporter.Process
 
  'Close the output file.
  Call Stream.Close
 
NextDoc:
  Set OneDoc = SelectedDocs.GetNextDocument(OneDoc)
 
 'End of loop on all selected documents.
 Wend
 
 Msgbox "Export XML file successful." + Chr(10) + Chr(10) + "Please check folder " + XML_OUTPUT_DIR,0,"Confirm"
 
NormalReturn:
 Exit Sub
 
ErrorReturn:
 Resume Next 
ErrorReturn2:
 Exit Sub
 
End Sub
 将XML文件导入为Notes文档
Sub Initialize
 
'Function NameXML Import to Doc                                               'Constants
 Const ERR_GENERAL = 1001
 
 'Variables
 
 Dim Sess As NotesSession
 Dim Stream As NotesStream
 Dim Importer As NotesDXLImporter
 Dim ThisDb As NotesDatabase
 Dim SelectedDocs As NotesDocumentCollection
 Dim OneDoc As NotesDocument
 Dim ws As New NotesUIWorkspace
 Dim files As Variant
 
 'Set up generic error handler.
 On Error Goto ErrorReturn
 
 'Get the current environment.
 Set Sess = New NotesSession
 Set ThisDb = Sess.CurrentDatabase
 
 'Create an XML importer tool and a stream to feed it.
 Set Importer  = Sess.CreateDxlImporter
 Set Stream = Sess.CreateStream
 
 'Tell the import tool to put the restored documents into this database, and to add them to existing docs (no over-write).
 Call Importer.SetOutput (ThisDb)
 Importer.DocumentImportOption = DXLIMPORTOPTION_CREATE
 
 files = ws.OpenFileDialog(True,"Please Select XML file.", "", "c:\notes_xml\")
 
 Forall XmlFilePath In files
 
  If XmlFilePath = "" Then Error ERR_GENERAL, "Could not find name of XML file."
 
      'Create an input stream from the XML file.
  Call Stream.Open(XmlFilePath)
  Call Importer.SetInput (Stream)
 
      'Do the conversion from XML to Notes.
  Call Importer.Process
 
      'Close the input file.
  Call Stream.Close
 
 End Forall 
 
 Msgbox "Import Doc from XML File successful.",0,"Confirm"
 
NormalReturn:
 Exit Sub
 
ErrorReturn:
 Msgbox "Problem.  Error message is: " & Error$, MB_ICONSTOP, "Error"
 Resume ErrorReturn2
ErrorReturn2:
 Exit Sub
End Sub