Get Ready to Work with MSXML (C-C++)

 

To work with MSXML, you must have:

  • An appropriate version of MSXML installed on your machine.

  • The MSXML libraries and headers incorporated into your project.

The following is a detailed discussion of these requirements.

To work with MSXML, you must have the module installed on your machine. To verify this, search for the **msxmlX.dll** libraries in the $sysRoot\system32directory, where X is the version number and $sysRoot is the system directory. By default, this is c:\windows for machines running Windows XP, and c:\WinNT for machines running Windows 2000. For example, installing MSXML 6.0 copies the msxml6.dll file (as well as msxml6a.dll and msxml6r.dll) to the system directory, and registers the DLL in the system's registry.

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.

There are two ways to configure your application to use the DOM interfaces: You can include headers and libraries manually or automatically. The first approach below is simple and traditional. Visual Studio does more work for you with the second approach.

To include headers and libraries manually

  1. Follow the instructions in the Include Headers and Libraries Manually demonstration.

If you want to use the #import directive, you can do so as follows:

To include headers and libraries automatically

  1. Add the following two lines to your source code:

#import <msxml3.dll> raw_interfaces_only

using namespace MSXML2;

You can include headers and libraries from other versions of MSXML in the same way, by using the appropriate version-specific DLL name (i.e. msxml4.dll, msxml5.dll, etc.) in the #import directive.

Microsoft recommends that you include headers and libraries manually, rather than using the #import directive.