Get Ready to Work with MSXML (Smart)
Programming with MSXML in C/C++ with smart pointer class wrappers requires the same basic components as programming without smart pointer class wrappers:
An appropriate version of MSXML installed on your machine.
The MSXML libraries and headers incorporated into your project.
If you are going to use Microsoft Visual Studio 2008, see Get Ready to Work with MSXML (C-C++) and Set Up My Visual C++ Project for instructions on how to install and use these components.
This topic describes how to incorporate headers and libraries into your project.
Importing Headers and Libraries
After MSXML is installed, you need to set up your application project so that calls to the MSXML-supported APIs are resolved properly when the application is built. In Microsoft Visual C++, you must import the MSXML headers and libraries into your project. This is a fairly simple task if you intend to use smart pointer classes to access interface pointers.
Using the #import Directive
To use the #import directive, you can insert the following statement at the beginning of your application code:
#import <msxml6.dll>
The statement instructs Visual C++ to generate the type library information contained in the msxml6.dll library. As a result, two header files, msxml6.tlh and msxml6.tli, are created in one of your project's folders. These files contain the required type library information, with interfaces also wrapped in smart pointer classes. You might find it helpful to examine the *.tlh and *.tli files if you have not used them before.
For more information, see The #import Directive.
Using Smart Pointer Classes
There are many advantages to using smart pointer classes. In addition to automating some object management tasks, such as calling the AddRef
method or the Release
method on an interface pointer, they make the API calling convention in C/C++ more consistent with that in script or Visual Basic. This is helpful to programmers who frequently use these languages.
You might want to use the raw COM interface pointers when performance is an important issue. The Program with DOM in C/C++ tutorial shows you how to do that.
The syntax used to call the XML DOM methods or properties using smart pointer classes differs from that using raw interface pointers. The following topics provide more information about using smart pointer classes.