4 Replies Latest reply on Sep 11, 2009 2:57 AM by SB Masthan

    Find XML tag

    SB Masthan



      Is there any way to find the tagged text and utilize them?


      For example, find "footnote" tagged text and move them to footnote option including tags.




        • 1. Re: Find XML tag

          Hi Mashtan


          For the first part, consider something along the lines of:


          #include "glue code.jsx";


          var myLookupRule = new LookupTaggedElementsRule("//footnote");

          __processRuleSet(myDocument.xmlElements.item(0), new Array (myLookupRule));

          // Toy around with myLookupRule.foundElements;



          function LookupTaggedElementsRule(myXPath) {

               this.foundElements = new Array();

               this.name = "LookupTaggedElements";

               this.xpath = myXPath;

               this.apply = function(myElement, myRuleProcessor) {


                    return true;



          1 person found this helpful
          • 2. Re: Find XML tag
            SB Masthan Level 1



            I haven't get any result. Could you assist me to find a tag (for example “footnote) and convert that tagged text to footnote in Indesign CS3 with jsx?


            I have the script to create footnote with character style as follows:


            app.findTextPreferences.appliedCharacterStyle = myDoc.characterStyles.item("footnote");

            var myFoundItems = myDoc.findText();

            var myFoot=myFoundItems[i].parentStory.footnotes.add(LocationOptions.BEFORE, myFoundItems[i].insertionPoints[-1]);

            But I need it for xmlTags instead of character style.

            Kindly assist.



            • 3. Re: Find XML tag
              தமிழரசன் ( Thamilarasan) Level 1

              Hi Masthan


              You need to use xpath concept to find a xml tag.



              function main(){
                  if (app.documents.length != 0){
                      var myDocument = app.documents.item(0);
                      var myRuleSet = new Array (new AddAttribute);
                          var elements = xmlElements;
                          __processRuleSet(elements.item(0), myRuleSet);
                      alert("No open document");
                  function AddAttribute(){
                      this.name = "AddAttribute";
                      this.xpath = "/devices/device/part_number";   
                      this.apply = function(myElement, myRuleProcessor){
                          myElement.parent.xmlAttributes.add("part_number", myElement.texts.item(0).contents);
                          return true;




              Have a look at scripting guide & scripts available with Indesign SDK.



              Till now Indesign footnotes support only non-xml!!!




              • 4. Re: Find XML tag
                SB Masthan Level 1

                Hi Thamil,


                Thanks. I have developed the script to move the footnote from XML. Now I have the problem that font styles/character styles like "italic”, “bold” etc are vanished in the footnote. Do you have any solution?