开发者

"MSXML2" has no member "IXMLDOMNode" problem in VC++ 2010

开发者 https://www.devze.com 2023-02-06 07:18 出处:网络
I\'m trying to compile a VC++ projec开发者_JAVA百科t I\'ve inherited that uses MSXML2. This is an ATL .EXE project. A header file includes the following:

I'm trying to compile a VC++ projec开发者_JAVA百科t I've inherited that uses MSXML2. This is an ATL .EXE project. A header file includes the following:

#include "msxml2.h"

using namespace MSXML2;

Preprocessor definitions include __USE_MSXML2_NAMESPACE__, which I added to the project because without it the MSXML2 namespace was undefined. Attempting to build this project I receive many errors of the form:

error C2039: 'IXMLDOMNode' : is not a member of 'MSXML2'

These errors are produced by declarations like the following

CComPtr<MSXML2::IXMLDOMNode> pNode;

Other members are not found, including IXMLDOMDocument and IXMLDOMNode.


You can fix this

  1. Include msxml2.h header.
  2. Remove USE_MSXML2_NAMESPACE and using namespace MSXML2 code.
  3. Use CComPtr<IXMLDOMNode> pNode; without namespace.

I've seen many projects using import keyword to ask Visual C++ to generate the header file from TBL using MSXML2 namespace. However, using header and linking to lib is my favorite way to avoid using import keyword as it is not c++ standard. The bottom line is to avoid mixing the two approaches when refreshing old projects, which will lead to problems like this.

0

精彩评论

暂无评论...
验证码 换一张
取 消