5 Replies Latest reply on Jan 16, 2012 1:56 AM by snegig

    delete attribute xml Tags Help Please

    snegig Level 1

      Hi,

      Can anyone suggest me the how i can del attribute in keyterm tags.

       

      Only delete attribute olinkend kt-real-zero

       

      Screen shot 2012-01-11 at 5.54.18 PM.png

       

      thank you

      Regards, snegig

        • 1. Re: delete attribute xml Tags Help Please
          absqua Level 4
          var doc = app.activeDocument,
                    attNodes = doc.xmlElements[0].evaluateXPathExpression("//keyterm[@olinkend = 'kt-real-zero']"),
                    i, l;
          for (i = 0, l = attNodes.length; i < l; i++) {
                    attNodes[i].xmlAttributes.item("olinkend").remove();
          }
          

           

          Jeff

          1 person found this helpful
          • 2. Re: delete attribute xml Tags Help Please
            snegig Level 1

            Hi Jeff,

             

            Thank you so much for script.

             

            (1) Problem=>

            Jeff but i have another problem when i run this script message again and again

            Screen shot 2012-01-13 at 10.26.30 AM.png

            i am click lots of time press OK OK OK then find result.

             

            (2) Problem=>

            My another problem is that if keyterm value change like this

             

            olinked = KT01401

            olinked = KT01402

            olinked = KT01403

            • 3. Re: delete attribute xml Tags Help Please
              snegig Level 1

              Hi Jeff,

               

              Thank you so much for script.

               

              (1) Problem=>

              Jeff but i have another problem when i run this script message again and again

              Screen shot 2012-01-13 at 10.26.30 AM.png

              i am click lots of time press OK OK OK then find result.

               

              (2) Problem=>

              My another problem is that if keyterm value change like this

               

              olinked = KT01401

              olinked = KT01402

              olinked = KT01403

               

              Kudos to you.

              Regards

              snegig

              • 4. Re: delete attribute xml Tags Help Please
                absqua Level 4

                1. I have seen the "Content contains characters which cannot be encoded." warning when importing xml, but have never tracked down what is going on. Nor have I ever seen content different in InDesign than what I was expecting after seeing this warning. Maybe it occurs when the xml being imported doesn't have the encoding attribute on the initial processing instruction, but InDesign figures out the encoding? I don't know.

                 

                2. If you want to remove any olinked attribute on keyterm elements, just change the xpath expression in .evaluateXPathExpression to //keyterm[@olinkend] . If you want to match multiple specific values, just do //keyterm[@olinkend = 'KT01401' or @olinkend = 'KT01402' or @olinkend = 'KT01403'].

                 

                Jeff

                • 5. Re: delete attribute xml Tags Help Please
                  snegig Level 1

                  Hi absqua,

                   

                  Thank you so much for you script.

                   

                  Thank you again for you heads up.

                  Kudos to you

                  regard

                  snegig