How do I loop over all the tagged xml elements in a story? I've created a reference to the xml elements of the story I want like this:
var xmlStory = myDoc.xmlElements[0].xmlElements[0];
In this structure I have elements <v>10</v> that I want to change to <v id="10">10</v>. I'd like to do this in InDesign scripting and not with XSL upon export because of the workflow I'm planning. I know I can loop over the children in the structure like this:
for(var i=0;i<xmlStory.xmlElements.length;i++){ if(xmlStory.xmlElements[i].markupTag.name == "v"){ xmlStory.xmlElements[i].xmlAttributes.add("id", xmlStory.xmlElements[i].contents); } }
This works fine for just the first level, but I want to find every element with the markup tag "<v>". These tags can appear at any level in the structure. How do I make sure all of them are included and not just the first child elements of the story element?