Search DominoPower's 10,675 Lotus-related article archive 
Home
EasyPrint
News details Click here for the RSS feed's XML code. This is not a browser URL.
Articles-only Click here for the RSS feed's XML code. This is not a browser URL.
Twitter Feed Click here for the Twitter feed.
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.


« Previous  ·  1  ·  2  ·  3  ·  Next »
Other articles you might like
Home > Internet Technologies > XML (11 articles)
   How to create a Web service to extract data from XML documents
   Building an XML based Content Management System using Lotus Domino: wrapping it up
   Building an XML based Content Management System using Lotus Domino: overview of the content administration system
Home > Microsoft Technologies (27 articles)
   Preparing for the impending IE7 release
   How to create animated, context sensitive help for the Notes client
   OLE automation primer
Home > Internet Technologies > RSS and blogging (11 articles)
   Integrating AJAX and RSS into Domino applications
   Introducing the DominoPower RSS feeds
   Bridging the communications gap with RSS
Get Weekly Email Updates
Subscribe to our regular weekly email newsletter. It's packed with tips, reviews, deep analysis, and the latest news.
 
Recent DominoPower Articles
What to look for in a Domino-based document management solution
Understanding Domino.doc end-of-life options
When the debugger won't debug hidden code that isn't hidden
What to do if the LotusScript debugger won't single-step over code
Top 10 ways to launch and build a Lotus consulting practice (with a little help from the Beatles)
Troubleshooting an OpenSuse Notes install
Incident report: denial of service attack against ConnectedPhotographer.com
Latest Lotus Headlines
SnTT - Enabling ALL the bells and whistles!
Tivoli Data protection causes Domino to crash
Fun when running DB2 CLP scripts
Introducing Flippr, the easy way to admin Quickr
DXL and fake security
Using search forms in IBM Workplace Collaborative Learning 2.7
Schmidt, Freed, and Gering on the OVF Toolkit
>> Read all the news
More from the ZATZ journals
Computing Unplugged: Eight steps to successful and reliable home backups
David Gewirtz Online: CNN commentary and analysis
OutlookPower: Can Outlook run when it's not running (and other mysteries)?
-- 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 --

Sophisticated Meets Simple For Document Management
Share. Control. Manage.
Documents, emails, and content in the context of how work is done. Native to Lotus Domino. The User Experience unseen for Lotus Domino. Do more with less. Really.

See the possibilities Docova unleashes for Lotus Domino.
ZATZ Home  ·  News  ·  Back Issues  ·  Credits/Trademarks ·  Link To Us
Copyright © 1998-2009, ZATZ Publishing. All rights reserved worldwide.
Editor's Login