1 Reply Latest reply on Jun 29, 2012 9:39 PM by Green4ever

    Javascript: Remove Unused Tag from Document based on name

    natdeamer Level 1

      I am trying to remove an unused tag from the document based on name. 


      I don't want to use app.activeDocument.deleteUnusedTags();



      The code below removes the association between the item and the tag - but still leaves the tag in the tags panel:


      var myDocument = app.activeDocument;

      var xmlElements = myDocument.xmlElements;


      for(var j=xmlElements.length-1; j>=0; j--){


             for(var k=xmlElements[j].xmlElements.length-1; k>=0; k--){

                  var xmlTag = xmlElements[j].xmlElements.item(k).markupTag;


                  if(xmlTag.name == "Tag1"){







      The code below deleted the tag and replaces it with Root - But I would like the pageitem to be untagged.


      var myDocument = app.activeDocument;

      var documentTags = myDocument.xmlTags;

      for(var l=documentTags.length-1; l>=0; l--){

          if(documentTags[l].name == "Tag1"){

              var xmlTag = documentTags[l];





      Hopefully I am just missing something simple here...

      Nathan Deamer