我需要在sqrt
的xml元素中插入一个单词m:msqrt
(没有标签的纯文本),如下所示:
我试过了:
var path = (app.activeDocument.fullName.parent.fsName).toString().replace(/\\/g, '/');
//path of active document(sample.indd)
var xmlPath = (app.activeDocument.fullName.parent.fsName).toString().replace(/\\/g, '/')+"/with_aid2.xml";
xmlFile = File (xmlPath);
if(xmlFile.exists){
xmlFile.open();
var myString = xmlFile.read();
xmlFile.close();
myXml = new XML ();
myXml = XML(myString);
var msqrtCount = myXml.xpath("//m:msqrt");
}else{alert(xmlPath+" doesn't exist!");}
for(var i=0;i<msqrtCount.length();i++){
var added = msqrtCount[i];
added.contents="sqrt";
}
我收到错误说无效的内容属性。