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.
Component | Description |
---|---|
Source: loadDOMRaw.cpp | Creates an XML DOM object and loads the resource file into the project's main directory. |
Resource: stocks.xml | An XML data file. |
Output | This is the output you should get when you build and run the loadDOMRaw project. |
To create the loadDOMRaw Visual C++ Project
- Create a Win32 console application in Visual C++. 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. For example, your directory might be C:\msxml5\sdk, with subdirectories named inc and lib.
- Add your directory to the standard include path. To do this in Visual C++, open the Options... panel from the Tools menu. Click the Directories tab, then select Include files from the Show directories for drop-down menu. Add your directory name, such as "C:\msxml5\sdk\inc", to the Directories textbox.
- Add your directory to the system library path. To do this in Visual C++, open the Options... panel from the Tools menu. Click the Directories tab. Select Library files from the Show directories for drop-down menu. Add your directory name to the Directories textbox.
- Include the required MSXML header file by inserting the following macro into the source code:
#include <msxml2.h>
- Link msxml2.lib to your project. To do this in Visual C++, open Project Settings by clicking Settings from the Project menu. Select the Link tab. Append "msxml2.lib" to the Object/library modules: textbox.
Next, we'll add the source code for this project.