5 Replies Latest reply on Aug 13, 2015 4:10 AM by BSKTCreation

    Search XML tags in InDesign

    SanjayIDS Level 1

      Is there any script form searching XML tags in InDesign CS4 documents.

        • 1. Re: Search XML tags in InDesign
          Level 1

          var myDoc=app.activeDocument; 

          var root = myDoc.xmlElements[0]; 

          var docTag = root.evaluateXPathExpression('//p/pageend'); 

          for(i=0; i<docTag.length; i++){ 

              var docPos = docTag[i].xmlContent.insertionPoints[0].parentTextFrames[0]; 

                 //alert("Page: "+docPos.parentPage.name); 

                  var myIDAttr = docTag[i].xmlAttributes.item("no").value;

                  //alert("no: "+myIDAttr); 

          • 2. Re: Search XML tags in InDesign
            SanjayIDS Level 1

            Thank you! But i don't know how to use this script. Please help me!

            • 3. Re: Search XML tags in InDesign
              BSKTCreation Level 2

              Hi Sanjay,

               

              To use this script do the following.

              1. Open the InDesign document.
              2. Open ExtendScript Toolkit (this is an Adobe application).
              3. Create a new script document in the toolkit.
              4. Change the application that the Toolkit is pointing to via the dropdown list at the top of the new script document (select InDesign)
              5. Paste the script provided into the new script document.
              6. Press F5 to run

               

              You can also save the script and access via InDesign's script window as well.

               

              I hope this helped you.

               

              Regards,

              Brett

              • 4. Re: Search XML tags in InDesign
                SanjayIDS Level 1

                Thank you Brett for explaining me how to use this script.

                 

                But when I press F5 to run the script, I got message saying "Execution finished. Result: undefined" and nothing has happened!

                • 5. Re: Search XML tags in InDesign
                  BSKTCreation Level 2

                  Hi Sanjay,

                   

                  This script should do what you want, its almost identical to the snippet provided with a change to the expression string.

                   

                  var myDoc=app.activeDocument; 
                  var root = myDoc.xmlElements[0]; 
                  var docTag = root.evaluateXPathExpression('//*');
                  for(var i = 0; i < docTag.length; i++){
                      $.writeln(docTag[i].markupTag.name); // for the tag name
                      $.writeln(docTag[i].contents); // for the contents
                      } 
                  

                   

                   

                  Brett