当我尝试使用我总是得到一个访问冲突DocumentElement
的XMLDocument
.我XMLDocument
根据一些文件的存在创建.
错误信息
项目project1.exe引发异常类EAccessViolation,消息'模块'地址0047B152中的访问冲突'project1.exe'.地址B1D59357'
我的代码
unit XMLBase;
interface
uses
SysUtils, xmldom, XMLIntf, XMLDoc, Forms;
type
TXMLbase = class
private
{ Private declarations }
public
XMLDocument1: TXMLDocument;
root: IXMLNode;
constructor Create;
end;
var
fn: string;
implementation
constructor TXMLbase.Create;
begin
fn := ChangeFileExt(Application.ExeName, '.xml');
XMLDocument1 := TXMLDocument.Create(nil);
XMLDocument1.Options := [doNodeAutoIndent];
XMLDocument1.Active := False;
//optional, is used to indent the Xml document
if FileExists(fn) then
begin
XMLDocument1.LoadFromFile(fn);
XMLDocument1.Active:= True;
root := XMLDocument1.DocumentElement; //<<--- Access Voilation
end
else
begin …
Run Code Online (Sandbox Code Playgroud) 我知道Delphi 7是用Object Pascal(Delphi)编写的,但自2003年12月发布的Delphi 8以来,它只是一个.NET版本,它将Delphi Object Pascal代码编译成.NET CIL.为此目的重写了IDE.