XML-error: Not well-formed (invalid token)
Hello,
I want a new XML structure in the Script from my InDesign CS6 (MAC 10.7.4) document. Here ist my little testscript:
var doc = app.documents.item(0);
var allStories = doc.stories;
newXML = new XML('<root></root>');
for(var i = 0; i < allStories.length; i++) {
var curStory = allStories;
for(var j = 0; j < curStory.textStyleRanges.length; j++) {
var textStyleRange = curStory.textStyleRanges
;
alert(textStyleRange.contents);
t = new XML('<content>' +textStyleRange.contents + '</content>');
newXML.appendChild(t);
}
}
alert(newXML);
The document has a text frame with the text, such as "C & A". When the script starts, it shows me the error message "XML-error: Not well-formed (invalid token)" on.
The problem with the "&" is. Probably also other Characters.
I think InDesign can automatically convert this into "&" or other entities, but how?
