Include Headers and Libraries Manually
In this exercise, you will practice how to explicitly include headers and libraries into your project. This is also called loading DOM "raw". This example is functionally identical to the Load an XML DOM Object from an XML File (C/C++) example that follows it. The only difference is the way these headers and libraries are included.
This project uses or creates the following files.
To create the loadDOMRaw Visual C++ Project
Create a C++ Win32 console application in Visual Studio 2008. For detailed instructions on how to do this, see Set Up My Visual C++ Project. Name the project LoadDOMRawProj.
To include headers and libraries manually
Locate the SDK directory installed by the appropriate MSXML package. By default for MSXML 6.0, your directory will be C:\Program Files\MSXML 6.0, with subdirectories named inc and lib.
Set up the include directory for Visual Studio. From the Tools menu, select Options. In the Options dialog box, expand Projects and Solutions. Select VC++ Directories. Select Include files in the Show directories for drop down box. Click the New Line button, and add a new line to the list of directories. Browse to the directory that contains the MSXML header file. For MSXML 6.0, by default, the directory is C:\Program Files\MSXML 6.0\inc. Click OK.
Set up the lib directory for Visual Studio. From the Tools menu, select Options. In the Options dialog box, expand Projects and Solutions. Select VC++ Directories. Select Library files in the Show directories for drop down box. Click the New Line button, and add a new line to the list of directories. Browse to the directory that contains the MSXML libraries. For MSXML 6.0, by default, the directory is C:\Program Files\MSXML 6.0\lib. Click OK.
Modify the project to link with the MSXML 6.0 library. In the Solution Explorer, right click on the project and select Properties. In the tree, expand Configuration Properties, and then expand Linker. Under Linker, click on Command Line. Enter msxml6.lib in the Additional options text box.
Include the required MSXML header file by adding the following preprocessor directives to the source code:
#include <objbase.h> #include <msxml6.h>
You need to include the appropriate header file for the version of MSXML that you want to use. For an explanation about which header files to include, and which libraries to link to, see Building MSXML Applications.
Next, we'll add the source code for this project.