Registriert seit: 6. Apr 2005
10.109 Beiträge
|
Re: TreeView als *.html-Datei speichern
24. Aug 2007, 22:18
Hallo,
hier noch ein Ansatz:
Delphi-Quellcode:
uses
StrUtils // DupeString()
;
// encode characters not allowed in html text
function HtmlText( const s: string): string;
begin
Result := s; // poor man's encoding
end;
procedure NodesToHtml(
node: TTreeNode; // node to start with
lines: TStrings; // stringlist to receive html
count: Integer; // number of nodes to process
const indent: string = ' ' // level indentation
);
var
s: string;
begin
lines.BeginUpdate; // pause rendering
if Assigned(node) then // safety first
begin
s := DupeString(indent, node.Level); // prepare indentation
lines.Add(s + ' <ul>');
repeat
Dec(count);
lines.Add(s + indent + ' [*]' + HtmlText(node.Text) + ' ');
if node.HasChildren then
NodesToHtml(node.getFirstChild, lines, node.Count, indent);
node := node.getNextSibling;
until not Assigned(node) or (count < 1);
lines.Add(s + ' [/list]');
end;
lines.EndUpdate; // restart rendering
end;
Gute Nacht
|
|
Zitat
|