在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;  

解决方案 »

  1.   

    不用TXMLDocument使用IXMLDOMDocument看看
      

  2.   

    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;