Hi all,
I m making xml file through lotus script and writing xml contents in a xml file using NotesStream class. Now problem is that i m successfully writing into a file but i could not find that file in my pc. its strange .
When i check the size of the file its showing well . But i donot know where it is created.
here is my code :
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim stream As NotesStream
Dim doc As NotesDocument
Dim xmlString As String
Set db=session.CurrentDatabase
Set view=db.GetView("EmployeeXML")
Set stream=session.CreateStream
Set doc=view.GetFirstDocument
xmlString ={<?xml version=\"1.0\" encoding=\"UTF-8\"?>}
xmlString= xmlString +"<employeeinfo>"
While Not doc Is Nothing
xmlString = xmlString +"<employee>"+"<empnumber>"+doc.Enumber(0)+"</empnumber>"
xmlString =xmlString +"<subject>"+doc.Etask(0)+"</subject>"
xmlString =xmlString +"<name>"+doc.ename(0)+"</name>"
xmlString =xmlString +"<salary>"+doc.Esalary(0)+"</salary>"+"</employee>"
Set doc=view.GetNextDocument(doc)
Wend
xmlString=xmlString+ "</employeeinfo>"
Print |<script>alert("| & xmlString &|")</script>|
flag=stream.Open("c:\lotus\notes\Lotusdemo.xml")
If flag=False Then
Print |<script>alert("| & "File Doesnot exist" &|")</script>|
Exit Sub
End If
stream.WriteText(xmlString)
Print |<script>alert("| & stream.Bytes &|")</script>|
Print |<script>alert("| & "File Successfully created " & stream.Bytes & "Size" &|")</script>|
Hope someone will suggest me where i m wrong .
Rishi
Subject: Problem in file handling on web
seems like you are doing this in a Web Agent. If so then the file will be created on the Server and not on your client since web agents execute on the server.
hope this helps !!
Ashish
Subject: RE: Problem in file handling on web
Yaa,
Ashish i got it . Now qestion is that how i can access this ??
Rishi
Subject: RE: Problem in file handling on web
Usually, you don’t have access to the file system (OS) of the production server. So you could attach this file and mail it to your self or store it in a notes document.
cheers !!
Ashish
Subject: RE: Problem in file handling on web
okay…Thnx ashish,
Rishi
Subject: RE: Problem in file handling on web
You need to be sure that the ID running the agent has appropriate access to create files on the server. To check you can look at the server document > security tab > agent restriction section. Read help on Run Restricted Lotusscript/Java agents and Run Unrestricted Lotusscript/Java agents fields.
Also make sure that the file is deleted once it has been mailed or stored in the document.
cheers !!
Ashish
Subject: RE: Problem in file handling on web
ya, its true.
I have all the rights to run the agent. Now its time to attach with document . But i m thinking for other option too. Bcoz first file generation, then attach with mail then from mail detach in local and then use…
its a long chain , isn’t it??
Rishi
Subject: RE: Problem in file handling on web
FYI :
Whenever u create a file through agent it will create in server where u run ur agent. at the same time u can acces a file from server also through createstream itself.
When u can able to create a file means u can access a file also am i rite.
instream = sess.createstream
instream.open(“Filepath”) - This stat to access file
another options to access files is input and output methods for more info search in help
hope u r clear now
kavitha
Subject: RE: Problem in file handling on web
can I just take a step back and ask what you’re trying to do?Are you trying to generate an XML file to send back to browser or web client?
if so, rather than writing to a file on the hard drive, just send it back using Print statements:
Print “Content-Type: text/xml”
Print “… …”
that’ll present the XML to the client directly.
HTH
Kiers
Subject: RE: Problem in file handling on web
Hi Kieran
I tried what u told in ur prev post, but its wrote like a plain text on the browser.But i need as a pure xml like when we generate using “?ReadViewEntries” Url.
Rishi
Subject: Demo Link
Just double checked it by creating a simple demo.
http://www.medders.org.uk/xmltest.nsf/xml
this agent runs the following code:
Sub Initialize
Print |Content-Type: text/xml|
Print |<?xml version="1.0" encoding="UTF-8"?>|
Print |<Blah><A>Data</A><B>Tester</B></Blah>|
End Sub
Have a look and see if it’s what you’re after.
CHeers
K
Subject: RE: Problem in file handling on web
Can you go through your code and make sure that there are no other print statements? If there are it will stop it working.The Contentr-Type print statment must be the first print statement in the agent.
HTH
Kiers
Subject: Problem in file handling on web
Hi
Well whenever u run an agent if u have any print statement it will treat as html not xml even if u have generated xml code inside the agent. XML Code will be inside the html tags.
and output will produce as html format not xml if u want to show as xml u have create a xml file seperately.
Kavitha
Subject: RE: Problem in file handling on web
Ya kavitha,
This is the thing i found . New for me …
Thnx
RIshi
Subject: RE: Problem in file handling on web
I’m afraid that’s not correct - if the first Print statement line in your agent is
Print “Content-Type: text/xml”
then the output will be treated as xml, not html.
Please see http://www.medders.org.uk/xmltest.nsf/xml as an example of this.
the agent runs 3 lines of code, all of which are print statements, this first being that described above.
Subject: One other point - download
One other thing you can do (and I don’t know if it’s relevant) is to force the browser to show an “Open/Save” dialog, rather than to just out put the file. This can be done with one extra line:
Print “Content-Disposition: Attachment;filename=test.xml”
which makes the full agent:
Print |Content-Type: text/xml|
Print |Content-Disposition: Attachment;filename=test.xml|
Print |<?xml version="1.0" encoding="UTF-8"?>|
Print |DataTester|
demo at http://www.medders.org.uk/xmltest.nsf/xmldownload
Just thought that this might be what the problem was regarding the way the browser treats it as html. If not, no worries
K