procedure TFrmmain.updatememo;
const
Name:
Array[0..1]
of String =('
german', '
english');
var
words: IXmlDomNodeList;
subNode: IXmlDomNode;
i, j: integer;
begin
LVwords.Items.Clear;
LVwords.Items.BeginUpdate;
words := xmlDoc.documentElement.selectNodes('
words');
for i := 0
to words.length -1
do begin
subNode := words.item[i].selectSingleNode('
german');
LVwords.Items.Add;
LVwords.Items[i].Caption := subNode.text;
with LVwords.Items[0].SubItems
do begin
for j := 0
to length(
Name) -1
do begin
subNode := words.item[i].selectSingleNode(names[j]);
if subNode <>
nil then
Add(subNode.Text)
else
Add('
');
end;
end;
end;
LVwords.Items.EndUpdate
end;
procedure TFrmmain.FormCreate(Sender: TObject);
begin
fapppath := Extractfilepath(Application.ExeName);
xmlDoc := CoDomDocument40.Create;
xmlDoc.setProperty('
NewParser', true);
if not fileexists(fAppPath + Database_FName)
then begin
xmlDoc.loadXML('
<?xml version="1.0"><vocabulary></vocabulary>');
end else begin
xmlDoc.load(fAppPath + Database_FName);
end;
if xmldoc.parseError.errorCode <> 0
then
begin
Messagedlg('
Das Databasefile ist nicht korrekt' + #10#13+
'
Das Programm wird nun geschlossen.' ,mterror, [mbOK], 0);
application.Terminate;
end;
updatememo;
end;