lcspace:?
(发表于2003-6-6 11:23:00)
lcspace:当xml不存在是运行本程序,这里是否有问题
LoadLog:
if(SUCCEEDED(hr))
{
hr = CoCreateInstance(CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER,
IID_IXMLDOMDocument, (void**)&m_pXMLDoc);
if(SUCCEEDED(hr))
{
m_pXMLDoc->load(COleVariant(m_strFileName), &bResult);
}
}
//取得根节点
m_pXMLDoc->get_documentElement(&pRootNode);
if(pRootNode == NULL) //无根节点
{
m_pXMLDoc->Release();
m_pXMLDoc = NULL;
//重新创建XML日值文件
CreateLogFile(m_strFileName);
goto LoadLog; //重新载入
}
else
{
Init();
}
(发表于2003-6-6 11:25:00)
force_eagle::)
不好意思!
忘了写初始化Ole失败的处理了!!!
(发表于2003-6-9 12:39:00)
a_fly://取得根节点
m_pXMLDoc->get_documentElement(&pRootNode);
程序在执行到这里的时候,出错、debug提示m_pXMLDoc不是作者能否解释一下啊,我刚开始学习xml,所以很多东西不懂
(发表于2003-6-9 19:01:00)
force_eagle: if(SUCCEEDED(hr))
{
hr = CoCreateInstance(CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER,
IID_IXMLDOMDocument, (void**)&m_pXMLDoc);
if(SUCCEEDED(hr))
{
m_pXMLDoc->load(COleVariant(m_strFileName), &bResult);
}
}
//取得根节点
m_pXMLDoc->get_documentElement(&pRootNode);
要改一下!!!!!
没有对加载文件和创建实例出错后返回处理
(发表于2003-6-12 14:22:00)
force_eagle:加上
if (OLE初始化)
{
..............
if (创建实例)
{
..........
}
else
{
_com_issue_error(hr);
}
}
else
{
_com_issue_error(hr);
}
(发表于2003-6-12 14:35:00)
elabs:内存泄漏的太厉害,你可以试试你用你的这个类不停的创建实力,就会发现大量的内存泄漏.
for(int i=0; i<200;i++)
{
CXMLLogfile log;
}
(发表于2003-12-20 8:55:00)
elabs:再有呢,你的析构函数中是否该加上
CoUninitialize();
(发表于2003-12-20 8:58:00)
elabs:战鹰你去试试这个内存就是泄漏的
#include
#include
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
HRESULT hr = S_OK ;
VARIANT_BOOL bResult;
IXMLDOMDocument* m_pXMLDoc;
hr = CoInitialize(NULL);
if(SUCCEEDED(hr))
{
hr = CoCreateInstance(CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER,
IID_IXMLDOMDocument, (void**)&m_pXMLDoc);
if(SUCCEEDED(hr))
{
COleVariant oleFileName = COleVariant(CString(_T("LOG.XML")));
m_pXMLDoc->load(oleFileName, &bResult);
oleFileName.Clear();
}
}
while (1) {
IXMLDOMElement * pRootNode, *element;
IXMLDOMNode *nLogItem;
hr = m_pXMLDoc->get_documentElement(&pRootNode);
CComBSTR bsLogItem = CComBSTR(_T("LogItem"));
m_pXMLDoc->createElement(bsLogItem,&element);
pRootNode->appendChild(element,&nLogItem);
element->Release();
nLogItem->Release();
pRootNode->Release();
}
m_pXMLDoc->Release();
CoUninitialize();
return 0;
}
(发表于2003-12-20 9:26:00)
elabs://而这个确没事,很是奇怪
#include
#include
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
HRESULT hr = S_OK ;
VARIANT_BOOL bResult;
IXMLDOMDocument* m_pXMLDoc;
hr = CoInitialize(NULL);
while (1) {
if(SUCCEEDED(hr))
{
hr = CoCreateInstance(CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER,
IID_IXMLDOMDocument, (void**)&m_pXMLDoc);
if(SUCCEEDED(hr))
{
COleVariant oleFileName = COleVariant(CString(_T("LOG.XML")));
m_pXMLDoc->load(oleFileName, &bResult);
oleFileName.Clear();
}
}
IXMLDOMElement * pRootNode, *element;
IXMLDOMNode *nLogItem;
hr = m_pXMLDoc->get_documentElement(&pRootNode);
CComBSTR bsLogItem = CComBSTR(_T("LogItem"));
m_pXMLDoc->createElement(bsLogItem,&element);
pRootNode->appendChild(element,&nLogItem);
element->Release();
nLogItem->Release();
pRootNode->Release();
m_pXMLDoc->Release();
}
CoUninitialize();
return 0;
}
(发表于2003-12-20 9:28:00)
hynnie:示例程序编译不通过嘛!!
没找到这些的定义哦
IXMLDOMElement
CLSID_DOMDocument
所以,第一步应该#import "msxml.dll"
At this point, you'll need to import the Microsoft XML Parser typelib (OLE type library). The simplest way to do this is to use the C++ #import directive. Simply open your project's stdafx.h file and add the following lines before the file's closing #endif directive.
#import named_guids
using namespace MSXML;
(发表于2004-5-20 14:08:00)
..........................................................................
--------------------next---------------------
阅读(325) | 评论(0) | 转发(0) |