Hier eine kleine Starthilfe:
Delphi-Quellcode:
function Occurrences(xn: IXMLNode; const literal: String): Cardinal;
var
Count: Cardinal;
i, iPos: Integer;
dn: IDOMNode;
nl: IDOMNodeList;
s: String;
begin
Count := 0;
nl := (xn.DomNode as IDOMNodeSelect).selectNodes('//text()');
for i := 0 to Pred(nl.length) do
begin
dn := nl.item[i];
s := dn.nodeValue;
iPos := Pos(literal, s);
while iPos > 0 do
begin
Inc(Count);
iPos := PosEx(literal, s, iPos + Length(literal));
end;
end;
Result := Count;
end;
procedure TDemoForm.CountButtonClick(Sender: TObject);
begin
with XMLDocument do
begin
FileName := 'Meine Filme.xml';
Active := true;
ShowMessage(IntToStr(Occurrences(DocumentElement, 'Ärzte')));
end;
end;
Grüße vom marabu