Copy link to clipboard
Copied
Dear Friends,
I need your help
How to duplicate XML Element for label and caption text?
My need: Example below:
Label >> Table A2.8 >> skip A2.8 >> A2.8-separate text (just alert)
Caption >> Hellow work >> Hellow work-separate text (just alert)
Table A2.8. Hellow Word
(to)
A2.8. Hellow Word >> (separate text frame) Duplicate XML Element.
This is possible to script? i don't how to start and end. Please suggest friends. I have place the screenshot below:
var tableTableCapXpath = "//jrnlTblBlock/p[@aid:pstyle='jrnlTblCaption']/bold/label"; //Duplicate label part
var tableXMLElementCap = curDoc.xmlElements[0].evaluateXPathExpression(tableTableCapXpath);
var tableTableCapXpath = "//jrnlTblBlock/p[@aid:pstyle='jrnlTblCaption']"; //Duplicate caption part
var tableXMLElementCap = curDoc.xmlElements[0].evaluateXPathExpression(tableTableCapXpath);
Please help and suggest friends
Thanks in Advance
KS
Copy link to clipboard
Copied
Not sure what you want to do exactly but xpath won't duplicate a xmlElement because it let you just target the nodes you are interested in.
However EvaluateXPathExpression will return an array of XMLElements if any is found.
var myXMLElements = someXMLElement.evaluateXPathExpression( someXPath ); //array of XMLElements objects
In the latter, you can reference a member of that array and call a regular duplicate method.
var sourceXMLElement = myXMLElements[0]; //A reference to the first child of the array
then duplicate
var dup = sourceXMLElement.duplicate();
It will copy the xmlElement just after the source so you may want to move the copy somewhere else;
dup.move ( LocationOptions.AFTER, someReferenceXMLElement );
FWIW
Loic
Copy link to clipboard
Copied
Hi Loic,
Thanks to your reply! and good suggestions Thanks.
Thanks
KS