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")
#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")