|
|
|
|
|
|
|
|
|
|
|
|
|
|
Parsing XML with LotusScript and Microsoft's XML object (continued)
Installing and loading MSXML Sadly, I haven't found a way of just installing the MSXML component by itself. MSXML only gets installed when you install Internet Explorer 5 or there is an earlier version in Internet Explorer 4. It also doesn't come with any documentation but there are books available (see the Product Availability and Resources section at the end of this article). There's also a comprehensive online tutorial on the Microsoft site. Once installed (you'll probably need to fully install IE5), try running the following agent:
Dim xml As Variant
Set xml = CreateObject("Microsoft.XMLDOM")
Msgbox xml.async
|
You should get the message 'True' when you run this. If you get an error, try re-installing Internet Explorer.
You can find this agent included as SimpleTest in the sample database. Download instructions are in Product Availability and Resources at the end of this article.
The initial XMLHeadlines agent I created a simple database with a single document called News. This had two rich-text fields, one for the XML original and one for my HTML output. My first agent, XMLHeadlines, would download an XML file, place the contents in the XML field, and parse the data. I would then walk the tree to get the information I wanted and wrap that in HTML. Luckily MSXML allows you to load a file from a local source, so I didn't have to spend loads of time online while I was debugging it.
There are a number of key pieces of the agent. Table A contains a list of code segments and descriptions.
| Code segment |
Description |
| Set xml = CreateObject("Microsoft.XMLDOM"). |
Creates an instance of the object in a variant. |
| xml.async=False |
Default is asynchronous loading. We need synchronous so it waits for the file. To speed up loading set validateOnParse=false as well so it simply checks for "well-formedness". |
| xml.load(URL or file name) |
Loads a file or a URL. Returns true or false. |
| originalfile$=xml.xml |
Returns the original XML as a string |
| title=xml.selectSingleNode("rdf:RDF/channel/title").text |
Get the value of a single node as a text string; returns DominoPower News Center in listing above. |
| set root=xml.selectNodes("rdf:RDF/item") |
Return a node list matching the given pattern (i.e. all the item nodes). Use Forall to run through the list. |
| link$=x.childNodes(1).text |
For each node in the node list, get the first child nodes' value; returns the link item in listing above. You can use x.childNodes(1).nodeName to get the name. |
This worked pretty well and gave me the data I wanted. However, I also wanted to try and use style sheets as an alternative. The advantage of style sheets is that you can have one XML file and get different outputs depending on which style sheet you use. This is a bit like using different sub-forms in a form.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Advertisement --
Learn Notes and Domino 8 at your place and pace!
Learn Notes and Domino in your office and/or home! TLCC's highly acclaimed distance learning courses for users, developers, and admins will enhance your career and your resume.
The many included activities and demos will make you a pro! Expert instructor help is a click away.
Click here to try a FREE demo course!! |
-- Advertisement --
Integrate your Notes Applications with Microsoft Office and Symphony
Integra for Notes Integrates Microsoft Office and/or IBM Lotus Symphony
Requires NO change to the design of the appliation or Installations of DLL's and EXE's
- Integra is a ready to use solution, enhance static reports with Excel data analysis, pivot tables, macros
- User friendly aproach, using a point and click access to features
- Reports from any Lotus Notes databases
- Runs reports through a Notes client, web browser and scheduled basis
- Allows use of LotusScript for advanced data manipulation
- Enables self service reporting capabilities to end-users
Learn more at www.integra4notes.com. |
|
|
|
|
|
|
|
|
|
|