2 Replies Latest reply on Oct 22, 2012 4:50 AM by CORE-LAB

    XML-error: Not well-formed (invalid token)

    CORE-LAB

      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[i];
              
               for(var j = 0; j < curStory.textStyleRanges.length; j++) {
                  var textStyleRange = curStory.textStyleRanges[j];
             
                  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 "&amp;" or other entities, but how?