Showing posts with label script library. Show all posts
Showing posts with label script library. Show all posts

Thursday, July 19, 2007

Simple LotusScript-library to fetch html/transform xml

I rewrote some of the code so that there only will be created one object per task. In my first version, I created an object per URL-call. In this version, only one object is created per task.

Text-file with code
Put code under '(declarations) in the file, into the declarations part of the scriptlib, and 'Terminate into the terminate part. The functions place themselves when you paste them.

'(declarations)
Dim httpobj As Variant
Dim source As Variant, style As Variant

'Terminate
Set httpobj = Nothing
Set source = Nothing
Set style = Nothing


If you want to get several XML-/XSL-files from the same source, you only need to login once per agent. If you're going to use the same XSL template for each xml-source, you only need to load this the first time.

'..
login = "https://server.com/names.nsf?login&"+_
"username=foo&password=bar"

xmlurl = "https://server.com/db.nsf/first.xml"
xslurl = "https://server.com/db.nsf/first.xsl"

'first call
Print transformXML( login, xmlurl, xslurl )
'..
'second call, same xsl-template
xmlurl = "https://server.com/db.nsf/second.xml"
Print transformXML( "", xmlurl, "" )
'..
'third call, different xsl-template
xmlurl = "https://server.com/db.nsf/view?ReadViewEntries"
xslurl = "https://server.com/db.nsf/view.xsl"
Print transformXML( "", xmlurl, xslurl )
'..