Article ID: 269194
When you use the #import feature of Visual C++ with the Msxml.dll, Msxml2.dll, or Msxml3.dll file, you may receive the following compiler error messages:
error C2872: 'DOMDocument' : ambiguous symbol
warning C4099: 'DOMDocument' : type name first seen using 'class' now seen using 'struct'
You may see many other C4099 and C2011 errors in the output as well.
error C2011: 'IXMLDOMImplementation' : 'struct' type redefinition
The #import feature includes a file named Comdef.h, which indirectly includes files that include Msxml.h. This is necessary because Comdef.h defines some common GUIDs and contains the following:
Because these types are referenced, it is important for the Msxml.h file to be included. This causes redefinitions when #import'ing on the XML dynamic-link library (DLL). The redefinition errors occur when you use the no_namespace attribute for #import. Here is an example:
The "ambiguous symbol" error can occur when you use a namespace with #import, and use the Msxml.h header file from the Platform Software Development Kit (SDK) or a newer preview XML SDK from the Web. Because the newer Msxml.h defines DOMDocument in the global namespace, and the #import defines it in another namespace, the symbol is ambiguous. Here is the code to reproduce the problem:
The "no_namespace" attribute cannot be used with #import with the XML DLL.
The "ambiguous symbol" error can be avoided by using the Msxml.h header file from the Visual C++ 6.0 Include folder. This Msxml.h file contains only the old XML definitions that are necessary to satisfy Comdef.h, but doesn't redefine such newer symbols as DOMDocument.
If you use the Platform SDK or XML SDK header files, you can add those Include folders after the Visual C++ Include folder when you use #import. To do this, in Visual C++, on the Tools menu, click Options, and then click the Directories tab.
If a newer version of MSXML has been installed in side-by-side mode, you must explicitly use the Globally Unique Identifiers (GUIDs) or ProgIDs for that version to run the sample code. For example, MSXML version 4.0 can only be installed in side-by-side mode. For additional information about the code changes that are required to run the sample code with the MSXML 4.0 parser, click the following article number to view the article in the Microsoft Knowledge Base:
305019For additional information, click the article number below to view the article in the Microsoft Knowledge Base:
(http://support.microsoft.com/kb/305019/EN-US/ )INFO: MSXML 4.0 Specific GUIDs and ProgIds
(http://support.microsoft.com/kb/316317/EN-US/ )PRB: Compiler Errors When Using #import with XML in Visual C++ .NET