Converting Notes documents into XML Files

Hi Everybody,

In my Notes Client Application I am containing few documents in a view. I need to convert those documents into xml files. I mean each document needs to create one XML file and need to send all those xml documents as an attachment in a mail.

As I am not much aware of this conversion I am feeing bit difficult can any one help me regarding this problem as it is urgent.

Thanks in Advance.

Subject: Converting Notes documents into XML Files

In the Designer Help, go to XML for Domino and begin reading. There are many methods to do what you want to do. You have to decide if you want to use LotusScript or Java.

Subject: LotusScript to Convert Selected Notes documents into XML Files

Here is the LotusScript to convert all selected documents into XML files. It is designed to run from a view. You can place it into a view Button, or into a Menu agent. It creates a file with the NoteID as the name, and with a file extension of “.xml”. To view it with a Web browser, though, you will need to place the files into a folder, and you will need to have a subfolder named “xmlschemas”. The xmlschemas subfolder will need to have the file, “domino_6_5.dtd”, or which ever is appropriate for your version of Lotus Notes.

As you can see, it is very easy to do in LotusScript.

Dim dcSel As NotesDocumentCollection, docSel As NotesDocument, docSelNext As NotesDocument

Dim sFN As String, streamXML As NotesStream, lDoc As Long

Dim session As NotesSession

Dim dbSel As NotesDatabase

Dim sSrch As String

Dim sRplc As String

Dim XMLexp As NotesDXLExporter



Set session = New NotesSession

Set dbSel = session.CurrentDatabase



Set dcSel = dbSel.UnprocessedDocuments

Set docSel = dcSel.GetFirstDocument()

Do Until docSel Is Nothing

	Set docSelNext = dcSel.GetNextDocument(docSel)

	

	Set streamXML = Nothing

	Set streamXML = session.CreateStream()

	If Not streamXML.Open("C:\Temp\" + docSel.NoteID + ".xml") Then

		Messagebox "Unable to open a new file in your C:\TEMP Folder", 0, "XML Write"

		Exit Sub

	End If

	Set XMLexp = Nothing

	Set XMLexp = session.CreateDXLExporter(docSel, streamXML)

	Call XMLexp.Process()

	Call streamXML.Close()

	

	Set docSel = docSelNext

Loop

Subject: RE: LotusScript to Convert Selected Notes documents into XML Files

Hi James,

Thanks for your response

I have pasted the code on a button in my view but when i am trying to open it in a browser. it is displaying an error.

In my notes there is domino_6_0_4.dtd under Notes\xmlschemas. Even then i am facing the below error

Error in browser:

XML page cannot be displayed

cannot view XML input using style sheet, please correct the error and then click the Refresh button, or try again later.

The system cannot locate the resource specified. Error processing

resource ’ xmlschemas/domino_6_0_4.dtd’.Error processing

resource ‘file:///C:/temp/932.xml’.Line 2,Position 57

Can you plz help me.

Thanks in advance.

Regards

Komala.

Subject: Location of XML dtd files for Lotus Notes

Look for the subfolder, “xmlschemas”, in your local Lotus Notes program directory. For example, on my PC, it is located at “C:\Program Files\Lotus\Notes\xmlschemas”. In that folder you will find all of the Document Type Definition (dtd) files for Lotus Notes. You should find the “domino_6_0_4.dtd” file at that location.

If you are trying to open your Notes document XML files from C:\Temp, then:

  1. Create a sufolder called: “C:\Temp\xmlschemas”.

  2. Copy the domino_6_0_4.dtd file from your Lotus Notes Program directory xmlschemas folder (“C:\Program Files\Lotus\Notes\xmlschemas\domino_6_0_4.dtd”) to “C:\Temp\xmlschemas”.

  3. Using a Web browser, open any of the Notes document XML files in your C:\Temp folder; for example, open “C:\Temp\932.xml”.

You should now have a nice view of the XML output of the Notes document with the Note ID “932”.

Subject: RE: Location of XML dtd files for Lotus Notes

Hi James

      Thank you.Now I am able to open XML file. but my another issue is I need to send those created files as an attachment in the mail. when I send it in the mail. the other person who receives the mail is not able to open the xml file. I guess the person who receives the files should also need to have notes installed to open the file(Notes\xmlschemas\domino_6_0_4.dtd).

Is it possible to open the file without installing notes by just creating folder xmlschemas and placing domino_6_0_4.dtd in the file?

Thanks in advance

Regards

Komala

Subject: RE: LotusScript to Convert Selected Notes documents into XML Files

Hi james

Thanks a lot now i am now able to create xml file.I copied and pasted my XML files in Notes folder it started working.now i need to modify the agent to send all those files in a mail.is it possible??

Thanks for ur kind help

Regards

Komala

Subject: Adding XML files to an Email

Create a Lotus Notes document in the current database, and add the XML file(s) you just created. Use the method: NotesRichTextItem.EmbedObject(EMBED_ATTACHMENT, “”, “C:\Temp\932.xml”). For your email, the “Body” would be the NotesRichTextItem you want to use.

Just loop through to add each of the files to your email, then send it (NotesDocument.Send()).

Of course, the recipients will also need the Document Type Definition file (“*.dtd”) in order to view your XML files using a Web browser.