Click here to Skip to main content
15,889,116 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying convert some of old project from vs2005 to vs2015 . Below is the error I am seeing while building it in 2015 . I dont see any problem while building in vs2005

error C2065: 'DOMDocument40': undeclared identifier


Below is the code. I am getting the error at the CreateInstance

#include "MsXml2.h"
#import <msxml4.dll>

MSXML2::IXMLDOMDocumentPtr pConfigXSDDoc;  
MSXML2::IXMLDOMDocumentPtr pDeviceXSDDoc;  
// load the XML file
MSXML2::IXMLDOMDocument2Ptr pXMLDoc;   
HRESULT hr = pXMLDoc.CreateInstance(__uuidof(DOMDocument40));


What I have tried:

After I change the below code from

#include "MsXml2.h"
#import <msxml4.dll>

to 
#import <msxml4.dll> rename_namespace(_T("MSXML"))

then the domdocument40 error was resolved . Below three errors still I am getting
CLSID_XMLSchemaCache40
CLSID_DOMDocument40
IID_IXMLDOMDocument2

Can I hardcode the classids which are mentioned in the below link and use it directly in my code <a href="https://msdn.microsoft.com/en-us/library/ms754671(v=vs.85).aspx">MSXML 4.0 GUIDs and ProgIDs</a>[<a href="https://msdn.microsoft.com/en-us/library/ms754671(v=vs.85).aspx" target="_blank" title="New Window">^</a>]
Posted
Updated 10-Jun-20 4:01am
v2

 
Share this answer
 
Comments
Coder969 31-May-17 7:50am    
Thanks for the response
After I change the below code from

#import <msxml4.dll>
using namespace msxml2

to
#import <msxml4.dll> rename_namespace(_T("MSXML"))

then the domdocument40 error was resolved . Below three errors still I am getting
CLSID_XMLSchemaCache40
CLSID_DOMDocument40
IID_IXMLDOMDocument2

In the provided link I can see the classids. Does this mean if I hardcode in my project CLSID_DOMDocument40 to {88d969c0-f192-11d4-a65f-0040963251e5} and use it in my project?
Richard MacCutchan 31-May-17 8:38am    
No, you should use the symbolic names as given in the MSDN documentation.
Coder969 31-May-17 21:48pm    
But I dont find the symbolic names in the headers files of vs2015
Richard MacCutchan 1-Jun-17 4:24am    
You need to study the documentation, which is the only place where you will find what needs to be done.
Just do 2 steps as below..

1. Specify header as #include <msxml.h>
2. Rename <domdocument40> to <domdocument> only as below,

// Format the XML. This requires a style sheet
MSXML::IXMLDOMDocument2Ptr loadXML;
hr = loadXML.CreateInstance(__uuidof(DOMDocument));
if(FAILED(hr))
{
ShowError(loadXML);
return;
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900