Skip to content
Search

MSXML

lastmod 2021-11-05created 2021-11-051 edits

MSXML (Microsoft XML Core Services) is a set of services that allows applications written with JScript, VBScript, and Microsoft development tools to build Windows-native XML-based applications. It supports XML 1.0, DOM, SAX, an XSLT 1.0 processor, and XML schemas including XSD and XDR.

Program with DOM in C/C++

Add the following two lines to your source code (To include headers and libraries automatically)

#import <msxml3.dll> raw_interfaces_only
using namespace MSXML2;

Set Up My Visual C++ Project: Initialize COM with CoInitialize and release it with CoUninitialize.

#include "stdafx.h"
#include <stdio.h>
#include <windows.h>
#include <objbase.h>
#include <msxml6.h>

int _tmain(int argc, _TCHAR* argv[])
{
   CoInitialize(NULL);
   printf("start using MSXML6\n");

   // Add your code here.

   CoUninitialize();
   return 0;
}

Additionally, as Windows versions have advanced, an extended initialization function can be used.

bool initializeCOM() {
#if _WIN32_WINNT >= 0x0400 & defined(_ATL_FREE_THREADED)
    CoInitializeEx(NULL, COINIT_MULTITHREADED);
#else
    CoInitialize(NULL);
#endif
    return true;
}

See also

Favorite site

author Zer0 sitemap