aardio 调用 C#程序读 Freeplane.mm文件,生成测试用例.csv文件

C# 请参阅:C# 用 System.Xml 读 Freeplane.mm文件,生成测试用例.csv文件

Freeplane 是一款基于 Java 的开源软件,继承 Freemind 的思维导图工具软件,它扩展了知识管理功能,在 Freemind 上增加了一些额外的功能,比如数学公式、节点属性面板等。

创建工程 xml2csv 编写  main.aardio 如下

import win.ui;
/*DSG{{*/
mainForm = win.form(text="xml2csv";right=757;bottom=467)
mainForm.add(
button1={cls="button";text="打开文件.mm";left=515;top=11;right=618;bottom=34;z=2};
button2={cls="button";text="转换为.csv";left=643;top=13;right=728;bottom=36;z=3};
edit={cls="edit";left=10;top=11;right=503;bottom=37;edge=1;z=1};
edit2={cls="edit";left=10;top=46;right=747;bottom=455;edge=1;hscroll=1;multiline=1;vscroll=1;z=4}
)
/*}}*/

import console;
import io;
import sys;
import fsys.dlg;
import process;
import web.msxml;
var xmlDoc;
var str, txt, lines;

mainForm.button1.oncommand = function(id,event){
	mainForm.button1.disabled = true;
	var file1 = fsys.dlg.open("*.mm|*.MM");
	if (!io.exist(file1)){
		mainForm.msgbox("file1 not exists.");
		mainForm.button1.disabled = false;
		return ;
	}
	mainForm.edit.text = file1;
	xmlDoc = web.msxml();
	xmlDoc.load(file1); 
	//console.log( xmlDoc.xml );
	//mainForm.edit2.text = xmlDoc.xml;
    // 遍历node节点,提取属性TEXT值
	root = xmlDoc.selectSingleNode("/map/node");
	lines = root.getAttribute("TEXT")++'\r\n';
	for(k,xnode in xmlDoc.eachNode("node", root)){
		if (xnode.getAttribute){
		  txt = xnode.getAttribute("TEXT");
		  lines += txt ++'\r\n';
		}
	}
	mainForm.edit2.text = lines;
	mainForm.button1.disabled = false;
}

mainForm.button2.oncommand = function(id,event){
	mainForm.button2.disabled = true;
	file1 = mainForm.edit.text;
	if (io.exist(file1)){
		if (process.isExe("\res\mm_Xml_csv.exe")){ // UTF8转GBK
			process.execute("\res\mm_Xml_csv.exe", string.fromto(file1,65001,936));
		} else {
			mainForm.msgbox("\res\mm_Xml_csv.exe not found.");
		}	
	} else {
		mainForm.msgbox(file1++" not found.");
	}
	win.delay(100);
	file2 = file1++".csv";
	if (io.exist(file2)){
		str = string.load(file2);
		mainForm.edit2.text = str;
	}		
	mainForm.button2.disabled = false;
}

mainForm.show();
return win.loopMessage();

运行(F5)  注意有中文文件名,需用  // UTF8转GBK

process.execute("\res\mm_Xml_csv.exe", string.fromto(file1,65001,936));

参阅:aardio:进程操作

  • 8
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值