For simplicity and clarity, the C/C++ applications presented in this tutorial are constructed as Win32 console application projects in Microsoft Visual Studio. The procedure below outlines the steps to build and run such a project.
To create a new Win32 console application project
Now you are ready to add source, header, and resource files to the project. For a clear illustration, each task in the How Do I Program with DOM in C++ tutorial is implemented as a standalone Win32 console application. The following skeleton code shows the general layout of these applications.
Source Listing for a Trivial Application (trivial.cpp)
#include <stdio.h> #import <msxml5.dll> raw_interfaces_only using namespace MSXML2; int main(int argc, char* argv[]) { CoInitialize(NULL); printf("start using msxml5.dll... \n"); // Add your comments here. ...CoUninitialize(); return 0; }
To add source code to your project
Note Before using any COM module, you must initialize the COM library by calling theCoInitialize(NULL)
function in your application. You then must close the COM library by calling theCoUninitialize()
function before the application exits.
To build and run the application
When you build and run trivial.cpp, you should get the following output:
start using msxml5.dll...
Now we are ready start working with XML DOM. First, we'll demonstrate how to include headers and libraries manually.