C# 请参阅:C# 用 System.Xml 读 Freeplane.mm文件,生成测试用例.csv文件
Freeplane 是一款基于 Java 的开源软件,继承 Freemind 的思维导图工具软件,它扩展了知识管理功能,在 Freemind 上增加了一些额外的功能,比如数学公式、节点属性面板等。
打开 lazarus-IDE,创建 project: xml2csv , 编辑GUI界面,编写 unit1.pas 如下
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs,
StdCtrls, Crt; // ShellApi,
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Edit1: TEdit;
Memo1: TMemo;
OpenDialog1: TOpenDialog;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
public
end;
var
Form1: TForm1;
fn1: String;
fn2: String;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
begin
if OpenDialog1.Execute then
begin
fn1 := OpenDialog1.FileName;
Edit1.Clear;
Edit1.Text := fn1;
end;
if FileExists(fn1) then
begin
Memo1.Lines.LoadFromFile(fn1);
end
else
ShowMessage(AnsiToUTF8(fn1+' 文件没找到'));
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
fn1 := Edit1.Text;
if FileExists(fn1) then
begin
// Simple one-liner (ignoring error returns) :
//if ShellExecute(0,nil, PChar('mm_Xml_csv.exe'),PChar(fn1),nil,1) =0 then;
SysUtils.ExecuteProcess('mm_Xml_csv.exe', Utf8ToAnsi(fn1), []);
delay(100);
end
else
ShowMessage(AnsiToUTF8(fn1+' 文件没找到'));
fn2 := fn1 +'.csv';
if FileExists(fn2) then
begin
Memo1.Lines.LoadFromFile(fn2);
end;
end;
end.
copy mm_Xml_csv.exe to projects\xml2csv\ 点击运行。
注意有中文文件名,需用 SysUtils.ExecuteProcess('mm_Xml_csv.exe', Utf8ToAnsi(fn1), []);
参阅:Executing External Programs