Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

how to select previous node indesign javascript

Community Beginner ,
Dec 04, 2019 Dec 04, 2019

how to select previous node indesign javascript

TOPICS
Scripting
759
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 04, 2019 Dec 04, 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 04, 2019 Dec 04, 2019

Untitled3.png

select  previous abstract node

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 04, 2019 Dec 04, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Dec 05, 2019 Dec 05, 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

}

}

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Dec 08, 2019 Dec 08, 2019
LATEST

if node.index is equal to zero then?

Definetely your code will meet an exception.

Correct?

 

Best

Sunil

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines