8 Replies Latest reply on Mar 24, 2017 4:04 AM by Laubender

    [JS/CS6] How can I reach or remove leftover text that's got stuck in the XML Structure

    Andreas Jansson Level 2

      Sometimes the remainders of deleted text are found at a parent or root level of the XML structure. How can I "find it" from scripting?



      Above, a sample image. The root should normally be just "<>", and there can exist hundreds of tagged elements under the root, that must not be removed. The only thing that is to be removed is the text that is showing inside the Root element, since it is not in use anywhere.


      To fix it the way I want it, I can manually drag the root element to the document, enter the Story Editor (Ctrl+Y) and delete the text. I do it in the story editor in order to avoid deleting all other child nodes of the root, which easily happens if i just delete the text in the textframe. When I delete the textframe, after having deleted the top level text that was "stuck" before, everything looks nice.


      I would like a to write a script that removes text that has got stuck in the root in the way that is shown in the image (the root is not placed on the page, so it should be empty in the case I'm on).


      Setting the contents of the xmlElement to '' results in all sub elements being deleted (not what I want).