unit1.pas

来自「delphi 中用于 css 样式表的解析的类」· PAS 代码 · 共 55 行

PAS
55
字号
unit Unit1;

// (C) 2005 MYTHcode.org

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, ToolWin, SubUtils, XMLParser;

type
  TForm1 = class(TForm)
    ToolBar1: TToolBar;
    ToolButton1: TToolButton;
    OpenDialog1: TOpenDialog;
    TreeView1: TTreeView;
    procedure ToolButton1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.ToolButton1Click(Sender: TObject);
var
  Parser: TXMLParser;
  ParentNode: TTreeNode;
begin
 if OpenDialog1.Execute then
 begin
   Parser:=TXMLParser.Create(File_(OpenDialog1.FileName));
   try
     ParentNode:=nil;
     with Parser, TreeView1.Items do
     while Next do
     case TagType of
       ttBeginTag: ParentNode:=AddChild(ParentNode, StepCode);
       ttEndTag: if ParentNode<>nil then ParentNode:=ParentNode.Parent;
       else AddChild(ParentNode, StepCode);
     end;
   finally
     Parser.Free;
   end;
 end;
end;

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?