1

Is there a way of looping through xml tags and output each tag onto a new page of an indesign document

Here is what i have so far but i think i am way off:

var myDocument = app.activeDocument;  
var root = myDocument.xmlElements[0];  
var myXMLidElement = root.evaluateXPathExpression("//c/p/TestTable");  
for (var i = 0; i < myXMLidElement.length; i++)  
{    
  myDocument.select(myXMLidElement[i]);  
  var myTextframe = myXMLidElement[i].placeIntoInlineFrame(["1p","1p"]);  
}   

The tag name is called "TestTable"

1

A possible approach :

var main = function() {

var doc = app.properties.activeDocument,
root, xes, xe, n = 0, i = 0, tf, pg,
props = {
    geometricBounds:[0,0,10, 100]
};

if ( !doc ) {
    alert("You need an open document" );
    return;
}

root = doc.xmlElements[0];  
xes = root.evaluateXPathExpression("//c/p/TestTable");  
n = xes.length;
while ( i<n ) {
    xe = xes[i];
    pg = doc.pages.add();
    tf = pg.textFrames.add(props);
    tf.markup ( xe );
    i++;
}}
var u;
app.doScript ( "main()",u,u,UndoModes.ENTIRE_SCRIPT, "The Script" );
  • Unfortunately, it doesnt do anything :( – lanes123 Apr 10 '18 at 8:00
  • I can't see any reason why it "wouldn't" work. The script creates frame on a per page basis. Have you check if some frames weren't created (maybe they have no fill/stroke). – Loic Apr 10 '18 at 15:59

Not the answer you're looking for? Browse other questions tagged or ask your own question.