惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
WordPress大学
WordPress大学
S
SegmentFault 最新的问题
小众软件
小众软件
爱范儿
爱范儿
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
量子位
博客园_首页
T
Tailwind CSS Blog
The Cloudflare Blog
J
Java Code Geeks
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
U
Unit 42
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
人人都是产品经理
人人都是产品经理
N
Netflix TechBlog - Medium
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
腾讯CDC
P
Proofpoint News Feed
aimingoo的专栏
aimingoo的专栏
Recent Announcements
Recent Announcements
T
The Blog of Author Tim Ferriss
D
Docker
Microsoft Azure Blog
Microsoft Azure Blog

博客园 - 今夜太冷

GPG(GnuPG)入门 Session variables lost after the call of Response.Redirect method c++中POD类型和non-POD类型 关于c++ template的branching和Recursion的一段很好的描述 How do I remove a particular element from an array in JavaScript? Get the client's IP address in socket.io 前端 使用 crypto-js 对数据进行对称加密 C++ delegate的几种方法 MFC更换窗口图标 boost::make_function_output_iterator报错: C4996 How to copy the contents of std::vector to c-style static array,safely? std::vector push_back报错Access violation Structured Exception Handling Catch a Memory Access Violation in C++ Windows上的字符转换之CP_ACP和CP_OEMCP Initialize a vector in C++ (5 different ways) MFC中使用ATL报错:error C4430: missing type specifier - int assumed. Note: C++ does not support default-int C++ WINDOWS下 wchar_t *和char * 相互转化总结篇 VS2008 编译出错 fatal error C1859: unexpected precompiled header error, simply rerunning the compiler might fix this problem
解析XML出错,无法创建DOMDocument对象
今夜太冷 · 2018-08-11 · via 博客园 - 今夜太冷

【问题】

加载XML配置文件时,创建DOMDocument对象总是失败,创建代码如下:

MSXML2::IXMLDOMDocumentPtr pXMLDoc;

MSXML2::IXMLDOMElementPtr xmlRoot;

//创建DOMDocument对象

HRESULT hr = pXMLDoc.CreateInstance(__uuidof(MSXML2::DOMDocument40));

if(!SUCCEEDED(hr))

{

AfxMessageBox(_T("无法创建DOMDocument对象,请检查是否安装了MS XML Parser 运行库!"));

return ;

}

以前都没这问题,今天不知道怎么一直这样,求大神指点

【回答】

我以前也碰过这个问题,那是因为没有安装xmldom 40或者坏了.
可以试试xmldom 26, xmldom 30, xmldom 60, 不要写死就只能创建40

[注]仿照这个,我写了如下的代码,就成功了

     HRESULT HR = XMLDOC.CreateInstance(_uuidof(MSXML2::DOMDocument40));

     if(!SUCCEEDED(HR))

     {

        HR = XMLDOC.CreateInstance(_uuidof(MSXML2::DOMDocument60));

        if(!SUCCEEDED(HR))

        {

            HR = XMLDOC.CreateInstance(_uuidof(MSXML2::DOMDocument30));

            if(!SUCCEEDED(HR))

            {

                HR = XMLDOC.CreateInstance(_uuidof(MSXML2::DOMDocument26));

                if(!SUCCEEDED(HR))

                {

                    goto EXIT;

                }

            }

        }

     }