Skip to main content
prtamil
Known Participant
August 26, 2017
Question

How to get the sibling comment in js

  • August 26, 2017
  • 1 reply
  • 412 views

Hi,

Can someone please help me to get the comment following term tag here in js.

Thanks

PR

This topic has been closed for replies.

1 reply

Loic.Aigon
Legend
August 28, 2017

Hi, you can do both ways:

var main = function() {

var doc = app.properties.activeDocument,

root;

if ( !doc ) return;

root = doc.xmlElements[0];

//Using XMLComments objects

alert ( "Using XMLComments objects inside InDesign:\r"+root.xmlComments.everyItem().value.join("\r") );

//Using XPath inside InDesign

var comments =  root.evaluateXPathExpression ( "//comment()" );

var txt = [], n = comments.length;

while ( n-- ) txt = comments.value;

alert( "Using xpath inside InDesign:\r"+txt.join("\r") );

}

var u;

app.doScript ( "main()",u,u,UndoModes.ENTIRE_SCRIPT, "The Script" );

I thought of using a xml object but xml export from indesign will remove comments :\

HTH

Loic