1 Reply Latest reply on Sep 26, 2012 8:42 AM by csm_phil

    Add XML Element ID to all elements as attribute


      Hi There,


      The title hopefully states what I like to get. I'm having quite some documents that are tagged, but want to add an id to all elements to allow for better XML manipulation outside on Indesign. I've been looking around a bit but seems to be not to many people ever bothered with...


      So, how do I traverse through all my XML elements, and add the element ID as attribute ?




        • 1. Re: Add XML Element ID to all elements as attribute
          csm_phil Level 4

          Hi Koen,


          Please try the below JS code. This code its working fine in InDesign CS5.5.



          var myDoc = app.activeDocument;
              var rootElement = myDoc.xmlElements.item(0);
              var linkElementList = rootElement.evaluateXPathExpression("//para");
              for(i=linkElementList.length-1; i>=0; i--){
                  var myAttribute = linkElementList[i];
                  myAttribute.xmlAttributes.add("idname", "idvalue");