procedure TForm1.Button1Click(Sender: TObject);
var
d : IHTMLDocument3;
c : IHTMLElementCollection;
i,entries : Integer;
n : IHTMLDOMNode;
s, datum, logger, group, text:
string;
tn: TTreeNode;
procedure AddFFTHeader (
const Node : IHTMLDOMNode;
var S :
string);
var
n : IHTMLDOMNode;
//-------------------Timestamp--------------------------------------------------
procedure AddFFTDateTime (
var Node : IHTMLDOMNode;
var S :
string);
begin
if not DOMNodeIsTextNode (Node)
then Exception.Create ('
AddFFTHeader Error!');
datum := Node.nodeValue;
Node := Node.nextSibling
end;
//-------------------logger-------------------------------------------------
procedure AddFFTName (
var Node : IHTMLDOMNode;
var S :
string;
const Name :
string);
var
n : IHTMLDOMNode;
begin
n := FindSpanByClassName (Node,
Name);
if not Assigned (n)
then Exception.Create ('
AddFFTName Error');
logger := n.nodeValue;
Node := Node.nextSibling
end;
//-------------------Group-------------------------------------------------
procedure AddFFTgroup (
var Node : IHTMLDOMNode;
var S :
string;
const Name :
string);
var
n : IHTMLDOMNode;
begin
n := FindSpanByClassName (Node,
Name);
if not Assigned (n)
then Exception.Create ('
AddFFTgroup Error');
group := n.nodeValue;
Node := Node.nextSibling
end;
begin
n := Node.firstChild;
AddFFTDateTime (n, S);
//Datum adden
AddFFTName (n, S, '
FFT_header_for_name');
AddFFTGroup (n, S, '
FFT_header_group');
end;
//-------------------TEXT -------------------------------------------------
procedure AddFFTText (Node : IHTMLDOMNode;
var S :
string);
begin
if not (DOMNodeTagNameIs (Node, '
div')
and DOMNodeClassNameIs (Node, '
fftText'))
then
Exception.Create ('
DOMNodeTagNameIs error: Weder div noch fftText gefunden');
Node := Node.firstChild;
if not DOMNodeTagNameIs (Node, '
pre')
then Exception.Create ('
DOMNodeTagNameIs error: pre Tag nicht gefunden');
if assigned(node)
then
begin
Node := Node.firstChild;
text := '
';
while Assigned (Node)
do
begin
if DOMNodeIsTextNode (Node)
then
text := text + '
' + Node.nodeValue;
Node := Node.nextSibling
end;
end;
end;
begin
d := WebBrowser1.Document
as IHTMLDocument3;
if not Assigned (d)
then
Exit;
c := d.getElementsByTagName ('
div');
for i := 0
to c.length - 1
do
begin
n := c.item (i, EmptyParam)
as IHTMLDOMNode;
if not Assigned (n)
then
Exception.Create ('
Fehlermeldung');
if DOMNodeClassNameIs (n, '
FFT_header')
then
begin
s := '
';
AddFFTHeader (n, s);
AddFFTText (n.nextSibling, s);
inc(entries);
label1.Caption := IntToStr(entries)+'
Einträge gefunden';
//Add Treenode
tn := Treeview.Items.Add(TreeView.Items.GetFirstNode, datum);
TreeView.Items.AddChild(tn, logger);
TreeView.Items.AddChild(tn, group);
TreeView.Items.AddChild(tn, text);
end
end
end;