-
1. Re: adding text to parentStory destroys XML element / JavaScript, InD CS4
Harbs. Jun 17, 2010 8:55 AM (in response to Dr. TYPO)Add the text to an insertionPoint. writing over the entire story contents will destroy anything in the story (including xml).
Harbs
-
2. Re: adding text to parentStory destroys XML element / JavaScript, InD CS4
Dr. TYPO Jun 18, 2010 1:32 AM (in response to Harbs.)Hello Harbs,
thank you, it almost works now; the xml element brackets are not destroyed anymore.
The only problem I have now is that the second element becomes a child of the first one.
How can I force each element to be "independent"?
Here's the code:
var MyBox = app.activeDocument.textFrames.add();
MyBox.geometricBounds = ["0pt","0pt", "200pt", "200pt"];var MyContent = "bla";
MyBox.parentStory.insertionPoints[-1].contents = MyContent;
MyBox.parentStory.characters.itemByRange(-1, -MyContent.length).select();
app.activeDocument.xmlElements.item(0).xmlElements.add("test1" ,app.activeDocument.selection[0]);MyContent = "456";
MyBox.parentStory.insertionPoints[-1].contents = MyContent;
MyBox.parentStory.characters.itemByRange(-1, -MyContent.length).select();
app.activeDocument.xmlElements.item(0).xmlElements.add("test2" ,app.activeDocument.selection[0]);Best regards,
TYPO
***


