0 Replies Latest reply on Dec 17, 2015 4:46 AM by heikog78609740

    How to get page ID for xmlElement

    heikog78609740

      In order to automatically create headlines for a document, I need to look-up text from an xmlElement and place the text into a new textFrame.

      The xmlElement appears randomly within the pages and therefore I need to extract text and corresponding page number.

      I tried by looping throught XML elements and get the elment text but not the page number it is located on.

       

      Can anyone give me a hint?

       

       

      Script

      var
           themarkuptag = 'Herstellername';
        

      travermlelements(app.activeDocument);

      function travermlelements(elm){

           var i;
           for (i = 0; i < elm.xmlElements.length; i++){

                   if (elm.xmlElements[i].markupTag.name == themarkuptag){
                      dothething(elm.xmlElements[i]);
                   }
                      travermlelements(elm.xmlElements[i]);
               }
           }

      function dothething(elm){

      if (elm.pageItems.length == 0){exit}
      alert(elm.contents);
      Alert(elm.parentPage.name);

      }