Copy link to clipboard
Copied
In javascript, I want to untag the selected elements(Element Name: ldinsert) without removing processing instruction(marked red color). Its possible while untagging manually but doing in ExtendScript toolKit i can't why???
Code used for untagging elements.
if(myElements[i].markupTag.name=="ldinsert")
{
myElements[i].untag();
}
Unfortunately from code xml instruction also will be removed.
To tackle this you can try untagging like this:
///////////////////////////////////////////////////////////////////////////////////
if(myElements[i].markupTag.name=="ldinsert"){
var myNode = myElements[i];
for(var p = 0; p < myNode.xmlInstructions.length; p){
myNode.xmlInstructions[p].move(LocationOptions.BEFORE, myNode);
}
myNode.untag();
}
////////////////////////////////////////////////////////////////////
...Copy link to clipboard
Copied
Not sure if this would help, but you could try just removing the tag.
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#XMLTag.html
if(myElements[i].markupTag.name=="ldinsert")
{
myElements[i].markupTag.remove();
}
Copy link to clipboard
Copied
Thanks for your reply.
Remove() function is contains replacewith parameter(its required, not optional) but i want to untag element without removing processing instruction and also content inside the untagged elements.
Copy link to clipboard
Copied
Unfortunately from code xml instruction also will be removed.
To tackle this you can try untagging like this:
///////////////////////////////////////////////////////////////////////////////////
if(myElements[i].markupTag.name=="ldinsert"){
var myNode = myElements[i];
for(var p = 0; p < myNode.xmlInstructions.length; p){
myNode.xmlInstructions[p].move(LocationOptions.BEFORE, myNode);
}
myNode.untag();
}
///////////////////////////////////////////////////////////////////////////////////
Best
Sunil
Copy link to clipboard
Copied
hi bro
i have a dout in un tag single xml element plz provide source code for this......
kindly send to my mail.id suriyag1210@gmail.com.
Copy link to clipboard
Copied
Unfortunately