Copy link to clipboard
Copied
Dear Java Expert.
I was try to script. Find/Change attribute(id) value for sequence order (attached screenshot for your reference). It is passable to script?
Example:
id = table8_3 change to id = table8_1
id = table8_3 change to id = table8_2
id = table8_3 change to id = table8_3
Please suggest friends.
Advance Thanks,
Hi,
Something like that ...
var doc = app.activeDocument;
var _XML = doc.xmlElements[0];
var _XMLelements = _XML.evaluateXPathExpression("//*/table[@id='table8_3']")
for(var i=0;i<_XMLelements.length;i++){
_XMLelements.xmlAttributes.item("id").value= 'table8_' + (i+1);
}
Regards
Copy link to clipboard
Copied
Hi,
Something like that ...
var doc = app.activeDocument;
var _XML = doc.xmlElements[0];
var _XMLelements = _XML.evaluateXPathExpression("//*/table[@id='table8_3']")
for(var i=0;i<_XMLelements.length;i++){
_XMLelements.xmlAttributes.item("id").value= 'table8_' + (i+1);
}
Regards
Copy link to clipboard
Copied
Hi Ronald63
Thanks so match Ronald.
I have run your script. I got result is undefined and also alert(_XMLelements.length); // Table length is 0?. What i mistake here Ronald. Please suggestion me.
Thanks
Copy link to clipboard
Copied
If your table is a direct child of the root, your xpath won't return anything as you are looking for a table inside any possible element starting from the root.
So
/root/xxxx/table => OK
/root/table => NO OK
You should use
var doc = app.activeDocument;
var _XML = doc.xmlElements[0];
var _XMLelements = _XML.evaluateXPathExpression("//table[@id='table8_3']")
for(var i=0;i<_XMLelements.length;i++){
_XMLelements.xmlAttributes.item("id").value= 'table8_' + (i+1);
}
Loic
Copy link to clipboard
Copied
Copy link to clipboard
Copied
You should have marked Ronald63's answer as corerct instead of mine. I have done much than refining the path.
Loic