1 Reply Latest reply on Apr 10, 2014 6:34 AM by Thomas Rüesch

    How to get the page item of an XML element?

    Thomas Rüesch Level 1

      Hello everyone,

       

      I'm fairly new to InDesign scripting (and to scripting in general) and having a lot of fun :-)

      I have a InDesign document containing several frames (text, graphics, etc.) and I tagged them using the Tags window of InDesign.

       

      After a lot of struggle, I managed to get the tag name of the first XML element in my document using this simple code:

       

      app.activeDocument.xmlElements[0].xmlElements[0].markupTag.name
      

       

      I know it worked because I got the correct answer in the Javascript console. (By the way, can somebody explain to me why I have to write xmlElements[0] twice?? And whats is the difference between xmlElements and xmlItems? Any help is appreciated).

      I will then probably use a for loop to get every markupTag of every xmlElement. But I have a lot of trouble to get the page item associated with the xmlElement :-/

       

      After a lot of googling, I stumbled upon this article which is supposed to answer exactly my question. I tried to understand this code, copy-pasted it in ExtendScript, but I have to admit this is a bit too complex for me…

       

      Can anybody tell me how to get a Graphic or Text Frame associated to my XML Tags? Any help is greatly appreciated!

        • 1. Re: How to get the page item of an XML element?
          Thomas Rüesch Level 1

          Nevermind, I found an easier way to achieve what I was trying to do. I actually wanted to be able to manipulate the different frames in my document, hence why I wanted to use XML tagging.

           

          For those of you that would have the same problem, know that since InDesign CS5, there's a itemByName method that allows you to select a frame by its name in the Layers Panel! So much easier to use :-)

           

          Thread closed!