【发布时间】:2016-08-24 04:01:14
【问题描述】:
我正在学习为adobe illustrator编写脚本的extendscript。我很难编写xml相关的解析。 我的问题陈述如下:-“我采用了三个文本框,即名称、城市和国家。”名称“是一个唯一的键。当我单击确定按钮时,如果名称不存在,则数据必须保存在 xml 中,否则更新以前的名称没有创建重复。xml文件中的所有名称都显示在列表框中。特定名称的日期可以通过删除按钮删除。这将删除列表框中所选项目中的数据。 我尝试做的代码是:-
var myWindow = new Window ("dialog", "Form");
var txt1 = myWindow.add ("edittext");//name unique
var txt2 = myWindow.add ("edittext");//city
var txt3 = myWindow.add ("edittext");//country
var btn=myWindow.add ("button", undefined, "OK");
btn.onClick = function () {
for (i=0;i<numberofnamesinxml;i++)//coding required
{
if(txt1.text!=xmlname[i]) // to verify name not there since it is like primary key
xmlFile.open("a");
xmlFile.write(root.toXMLString());
xmlFile.copy ('C:/data.xml');
xmlFile.close();
//myList refresh
}
}
var myList = myWindow.add ("listbox");
for (i=0;i<numberofnamesinxml;i++)//coding required
{
config='C:/data.xml';
config.open("r");
data= xmlname[i] //here i need to set data to
config.close();
myList.add ("item", data);
}
var btn1=myWindow.add ("button", undefined, "remove");
btn1.onClick = function () {
myList.remove (myList1.selection[i]);
//xml data having this list name must be removed
}
myWindow.show ();
请帮帮我。
【问题讨论】:
-
我建议尽可能使用 JSON。 ExtendScript 的 xml 特性缺少很多功能。我试图写一些适合你需要的东西,但是在尝试检查元素是否已经存在时遇到了问题。我会发布代码,但不认为它是一个完整的工作答案。
标签: javascript xml adobe-illustrator extendscript adobe-scriptui