works fine on my end, but that is one very very very weird code snippet:
1) why are you using triple quotes? this is not python?
2) why use that weird construct xml[xml.length] instead of xml ?
3) why use an array instead of a native XML object?
1. I don't want to escape special characters so it was easier to just compose with triple quotes than escape quotes. ie. <generalfeedback format="html"> 2. My understanding is there is two ways to add objects to an array. arr.append(obj) OR arr[arr.length] = obj. As far as I know it's not an obscure style, and if I remember correctly the second method is fractionally quicker. 3. I'm writing the XML to a File at the end of the script. *shrugs* Is there an advantage to writing as a "native XML object"?
What does 'works fine on your end' mean? The first snippet, second snippet? If the first snippet works on your end then are you using CC 2014? I've tried both ExtendScriptToolkit and InDesign as targets and both hang.
Thanks for the gander,
I get the script hang when using CDATA with E4X as well, Loic. My solution is to run the script from another script.
this seems to be a bug with CDATA (IMHO since CS5)
var xml = ; var Question = "Foo"; xml[xml.length] = "<text><![CDATA[<p>"+Question+"<br></p>]]\></text>";
This should do the job.
FWIW — it's maybe related, maybe it's not: I also had some problems with the ESTK, InDesign CS5 and a ![CDATA-error.
If I ran a script on an InDesign Table object and tried to read out or to assign its contents value the ESTK always throws an error: "![CDATA"
However if I ran the script from InDesign CS5, no error was thrown. That specific error went away with the CS6 version of the ESTK.
However, i just tested again the code using ESTK CC, and both original snippets seem to work just fine.
Various CDATA problems were fixed in the ESTK I think in CS6 (maybe CS5.5).