I have a script that replaces all the content in Indesign that i have tagged with labels in table cells which works great. The only thing lacking is when i give 2 cells the same label, the script only replaces the content of the first label it finds. So i want the script to replace every content that has the same label. Does anyone have an idea on how to achieve this?
var main = function() {
var doc = app.properties.activeDocument,
root, xe, price,
tags = <tags>
<PVDF8HNAPK40>100</PVDF8HNAPK40>
<PVDF8HNAPK50>100</PVDF8HNAPK50>
<PVDF8HNAPK63>100</PVDF8HNAPK63>
<PVDF8HNAPK75>100</PVDF8HNAPK75>
</tags>, tag, xes;
if ( !doc ) return;
root = doc.xmlElements[0];
tags = tags.children(), n = tags.length();
while ( n-- ) {
tag = tags[n];
xes = root.evaluateXPathExpression ( ".//"+ String(tag.name()) );
if ( xes.length ) {
xe = xes[0];
xe.contents = String(tag).replace (/\./g, "," );
}
}
}
var u;
app.doScript ( "main()",u,u,UndoModes.ENTIRE_SCRIPT, "The Script" );