Copy link to clipboard
Copied
Hi...
I want to create new parent element of tag through scripting just like we do manully in indesign.
Thank you.......
Hello payalm,
Try this below code for your reference,
var myDoc = app.documents[0]
var myCurrentNode = app.selection[0];
var parentNode = myCurrentNode.parent.xmlElements.add('TestNode');
parentNode = parentNode.move(LocationOptions.BEFORE,myCurrentNode);
myDoc.recompose();
myCurrentNode = myCurrentNode.move(LocationOptions.AT_BEGINNING,parentNode);
Copy link to clipboard
Copied
Hello payalm,
Try this below code for your reference,
var myDoc = app.documents[0]
var myCurrentNode = app.selection[0];
var parentNode = myCurrentNode.parent.xmlElements.add('TestNode');
parentNode = parentNode.move(LocationOptions.BEFORE,myCurrentNode);
myDoc.recompose();
myCurrentNode = myCurrentNode.move(LocationOptions.AT_BEGINNING,parentNode);
Copy link to clipboard
Copied
What is node?
Copy link to clipboard
Copied
I already found that exception and edited that answer as well.
Try it now.
Copy link to clipboard
Copied
This way, we will lose some style formatting. The better way is to use "Side Menu \ New Parent Element". But how to trigger this side menu option through scripting? Any idea?