I didn't know how to exactly write my question, as I have two different ones.
Firstly:
Is it possible to prepend XML Elements? I am adding xml elements via a custom panel, and at the end of the script, the rest of the elements are being added. But I need the elements which are added at the end to be prepended.
Secondly:
Why does the following snippet not work(I have minimised it to the essential code)?
with(rootXmlElement){
newElement = xmlElements.add('carl', yourSelection);
newElement.xmlElements.add('newXMLElement');
}
While this:
with(rootXmlElement){
newElement = xmlElements.add('carl');
newElement.xmlElements.add('newXMLElement');
}
works? I figured, that when you link the xmlElement to some object, the Element is somehow different, that it has no "xmlElements.add" anymore. But I just can't find a solution to this.
Any help is greatly appreciated. If someone has, I would love a great documentation about XML in indesign scripting, as the official scripting tutorial is not offering really much to it.