adobeindesign JavaScript XML:如何以编程方式添加XML结构标记?
This code references the root XML node, adds a FirstXMLObject under it, then adds a few fields under FirstXMLObject:
此代码引用根XML节点,在其下面添加FirstXMLObject,然后在FirstXMLObject下添加几个字段:
var myXMLroot = mydocument.xmlElements.item(0); // The root always exists
var b = myXMLroot.xmlElements.add( "FirstXMLObject");
b.xmlElements.add( "Name", "Bob");
b.xmlElements.add( "Address", "1234 Sesame Lane");
Supposedly, the second parameter to "add" is the value of the field. However, when I drag the associated InDesign tag to a document, nothing shows up.
应该说,“add”的第二个参数是字段的值。但是,当我将关联的InDesign标记拖到文档时,什么也没有显示。
What method or parameter do I set the value of the XML Element so that it links to InDesign? Is there some book that lists these methods and how to use them using JavaScript?
如何设置XML元素的值,使其链接到InDesign?有没有什么书列出了这些方法,以及如何使用JavaScript?
I was able to get InDesign ExtendScript to load MS ASP.NET MVC 2 JSON serialize products to a single JavaScript variable using eval. Now I need to get those products in the XML structure pane.
我能够让InDesign ExtendScript加载MS ASP。NET MVC 2 JSON使用eval将产品序列化为单个JavaScript变量。现在我需要在XML结构窗格中获得这些产品。
1 个解决方案
#1
0
I ended up doing this:
最后我这样做了:
var myXMLroot = mydocument.xmlElements.item(0); // The root always exists
var b = myXMLroot.xmlElements.add( "FirstXMLObject");
var c = b.xmlElements.add( "Name");
c.contents = "Bob";
var d = b.xmlElements.add( "Address");
d.contents = "1234 Sesame Lane";
And this for images (on a Mac):
这是图片(在Mac上):
e.xmlAttributes.add("href", "file://" +
varPathToImage.replace(/^.?:\\/i, "G:").replace(/\\/g, ":"));
This for a PC:
这对一个电脑:
e.xmlAttributes.add("href", "file://" + varPathToImage);
And this to determine which one to use:
这就决定了使用哪一个
if( File.fs == "Windows")
更多相关文章
- HTML Select字段通过ajax调用Web服务
- 阻止用户在表单字段中输入
- CORS错误:请求标头字段预检响应中的Access-Control-Allow-Headers
- 如何在选择单选按钮时显示文本字段
- 将输入文本字段显示为纯文本
- 在用户将'n'粘贴复制到文本字段后,如何更新视图模型?
- 带有无线电的JavaScript条件字段不起作用
- 如何在onchange()事件后调用的方法中将焦点设置为输入字段?
- 在Javascript中将下拉字段乘以文本字段