在DLL中可以操纵XML,取出IXMLNODE结点吗?

visiond 2004-07-05 09:37:14
在DLL中可以操纵XML,取出IXMLNODE结点吗。我向普通应用程序一样,在Dll中操纵Xml,可是一到取出IXMLnode结点时,就出错,
不知为什么,请高手指教。(try后第三句出错,文件存在且正确,在Exe程序中通过,一到Dll就出错)。
try
XMLDoc := TXMLDocument.Create(nil);
XMLDoc.LoadFromFile(gFileName);
GisXMLDocNode := XMLDoc.DocumentElement; //功能树配置文件的DocumentElement结点
finally
XMLDoc.Free;
end;
...全文
154 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Eastunfail 2004-07-05
  • 打赏
  • 举报
回复
哇~~~~倒分啊
tttk 2004-07-05
  • 打赏
  • 举报
回复
var
Doc: TXMLDocument;
begin
Doc := TXMLDocument.Create(nil);
end;

The important thing to notice is that you are passing in nil as the owner. What happens then is that TXMLDocument takes on a different behavior; it acts as a reference counted object that automatically frees itself when those references reach zero. This means that the next time you do something to Doc that causes a decrease in the reference count, you run the risk of destroying the object and invalidating your reference. The problem is that so much happens to TXMLDocument behind the scenes, inside of the VCL, that it is hard to say when exactly the reference count is getting modified. The easiest way to get around this is to use an interface pointer instead of a TXMLDocument reference, like so:

var
Doc: IXMLDocument;
begin
Doc := TXMLDocument.Create(nil);
end;

Eastunfail 2004-07-05
  • 打赏
  • 举报
回复
不用TXMLDocument使用IXMLDOMDocument看看

1,594

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 网络通信/分布式开发
社区管理员
  • 网络通信/分布式开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧