2 Replies Latest reply on Jul 26, 2013 1:05 AM by Vimala lakshmanan

    How to untag certain sublevel tags within a document?

    Vimala lakshmanan Level 1

      Hi..,

       

      I am trying to write a javascript for untag certain sublevel tags within a document.

       

      https://files.acrobat.com/preview/685416e4-6b78-4cbc-81ce-1e0e087d419e

       

      For example,in the above link i have attached one sample xml file..please refer it and from that xml i need to untag all except the "products". If it is possible kindly help me if anyone has any idea regarding this.

       

      Thanks,

      Vimala L

        • 1. Re: How to untag certain sublevel tags within a document?
          Mac_rk Level 2

          try this

           

          #include "glue code.jsx";

          var myDoc = app.activeDocument;

          var myRuleSet = new Array (new unTag);

          with(myDoc){

              var elements = xmlElements;

              __processRuleSet(elements.item(0), myRuleSet);

          }

           

           

          function unTag(){

              this.name = unTag;

              this.xpath = "//Root/*";

              this.apply = function(myElement, myRuleProcessor){

                  __processChildren(myRuleProcessor);

                  with(myElement){

                      try{

                          if(myElement.markupTag.name!='products'){

                              alert("ss")

                              myElement.untag();

                              }

                          }catch(e){}

                      }

                  return true;

                  }

              }