O'Reilly logo

Access Data Analysis Cookbook by Wayne S. Freeze, Ken Bluttman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Working with XML via the MSXML Parser

Problem

XML seems like a good solution for my problem, but none of Access' tools can handle the type of data I need to display. How can I build my own XML documents?

Solution

Included with Access 2003 is an external library that you can add to your VBA programs. It provides a complete set of objects that allow you to build a tree structure that will eventually form your XML file.

To use this library, you need to add it to your application. Choose Tools → References in the Visual Basic Editor to display the References dialog box (as shown in Figure 7-18), and select Microsoft XML, v5.0 from the list of references.

Adding Microsoft XML v5.0 to your application

Figure 7-18. Adding Microsoft XML v5.0 to your application

Tip

There are several versions of the Microsoft XML library. As long as you choose v3.0 or later, it really shouldn't matter which version you use. I chose v5.0 because it's installed along with Access 2003/2007.

The following routine uses two objects from the Microsoft XML library: the DOMDocument object, which provides the overall structure for the document, and the IXMLDOMElement object, which stores the information for a single node.

When working with the objects from this library, you use the New keyword to create an instance of the DOMDocument object, and then you use the appropriate Create method from the DOMDocument object to create any other objects you need. Once you've created ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required