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

How to Untag the Elements without removing processing Instruction

Community Beginner ,
Aug 03, 2020 Aug 03, 2020

Copy link to clipboard

Copied

manikandand34755096_1-1596468224008.png

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();
}

 

TOPICS
Bug , Performance , Scripting , SDK

Views

947

Translate

Translate

Report

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

correct answers 1 Correct answer

Advocate , Aug 05, 2020 Aug 05, 2020

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();
    }

////////////////////////////////////////////////////////////////////

...

Votes

Translate

Translate
Community Expert ,
Aug 03, 2020 Aug 03, 2020

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();
}

 

 

Votes

Translate

Translate

Report

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 ,
Aug 03, 2020 Aug 03, 2020

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.

Votes

Translate

Translate

Report

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 ,
Aug 05, 2020 Aug 05, 2020

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

Votes

Translate

Translate

Report

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
New Here ,
Oct 19, 2022 Oct 19, 2022

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

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
New Here ,
Jan 03, 2021 Jan 03, 2021

Copy link to clipboard

Copied

Unfortunately 

Votes

Translate

Translate

Report

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