Skip to main content
December 5, 2019
Question

how to select previous node indesign javascript

  • December 5, 2019
  • 2 replies
  • 733 views

how to select previous node indesign javascript

This topic has been closed for replies.

2 replies

December 5, 2019

you  can access previous siblings or child by using

var myDoc = app.documents[0];

var xPath = "//kwd-group"
var root = myDoc.xmlElements[0];
var node = null;
var proc = app.xmlRuleProcessors.add([xPath]);
var match = proc.startProcessingRuleSet(root);
while (match != undefined) {
node = match.element;
match = proc.findNextMatch();
if (node != null && node != undefined) {

node.parent.xmlElements[node.index-1]/////////////this will give previous Node

}

}

 

Sunil Yadav
Legend
December 9, 2019

if node.index is equal to zero then?

Definetely your code will meet an exception.

Correct?

 

Best

Sunil

Community Expert
December 5, 2019

Can you add more details as to what is the node that you are reffering to. Add in some code snippet that you have written and is not working as expected, or give some screenshots of the document if you don't even know where to start with your code. Just a terse statement is not going to help us in helping you

 

-Manan

-Manan
December 5, 2019

select  previous abstract node

December 5, 2019

var myDoc = app.documents[0];

var xPath = "//kwd-group"
var root = myDoc.xmlElements[0];
var node = null;
var proc = app.xmlRuleProcessors.add([xPath]);
var match = proc.startProcessingRuleSet(root);
while (match != undefined) {
node = match.element;
match = proc.findNextMatch();
if (node != null && node != undefined) {
graphicLink=node.previousNode;

}

}

how to select abstract element.