var
xml: TXMLDocument;
node, node2, node3: IXMLNode;
strFile2: String;
begin
strFile2 := AddPathSeparator(ExtractFilePath(Application.ExeName)) + 'history.xml';
xml := TXMLDocument.Create(nil);
if FileExists(strFile2) then begin
xml.LoadFromFile(strFile2);
node := xml.ChildNodes.First;
end else begin
node := xml.AddChild('history');
end;
xml.Active := True;
node2 := node.ChildNodes.FindNode('g' + IntToStr(Tag));
if node2 = nil then
node2 := node.AddChild('g' + IntToStr(Tag));
node3 := node2.ChildNodes.FindNode('d' + DateToStr(Date));
if node3 = nil then
node3 := node2.AddChild('d' + DateToStr(Date));
strList := TStringList.Create;
strList.Add('Tutaj przypisanie jakichś wartości');
strList.Add('Tutaj przypisanie jakichś wartości');
node3.Text := node3.Text + #13#10 + strList.Text;
strList.Free;
xml.Active := False;
xml.SaveToFile(strFile2);
xml.Free;
end;
Podczas próby wykonania tego kodu wyskakuje błąd
Access violation at address 00000000. Read of address 00000000.
Czasem też wyskakuje ten sam błąd, z innym adresem wskazujący na ten fragment kodu w module XMLDoc
function TXMLNode._Release: Integer;
begin
Result := inherited _Release;
if (Result > 0) and FIsDocElement and (FDocument <> nil) then
FDocument._Release; // Tu błąd
end;