I tried to import some XML (well structured code) to add some data to my Indesign Identifications Cards. But it wasn't well structured in the Story Editor. So first I designed one of the pages with all tags, pragraph styles, corrected with the Story Editor and exported it. Now it works perfect and looks good, even if I import it again. The problem is the code which is exported is not well structured any more when I open it with another text Editor and if I correct it, then I can not import it in Indesign without the problem recurring.

e.g. well structured code:


e.g. poorly structured code:

  • Hi. Welcome to GDSE. I think there seems to be some translation errors in your question, and I can't be sure what you are asking. "Gut instructured" makes no sense in English. Do you mean "well structured"?
    – Billy Kerr
    Commented Jun 13, 2019 at 11:10
  • @Billy Kerr sorry for my English mistakes. yes, actually I tried to write an Example of my code, but I can't do this as a comment. with "good instructured code" I meant every tag starts on a new line and children should have space from start of the line.
    – HamiD
    Commented Jun 14, 2019 at 12:34
  • 1
    Instructured isn’t a word – it looks like you mean a combination of structured and indented. Well-structured (= well-formed) XML does not have to be indented or have line breaks to be well-structured; indentation is just there to make it easier to read for humans – it makes no difference to the XML. When you import the XML into InDesign, however, you have to make sure the “Preserve white space” option in the import settings matches how your XML file looks. Can you show us a screen shot of your XML import settings dialog box? Commented Jun 16, 2019 at 19:04
  • @Billy Kerr: I've already tried this Option as well, but no luck :/ > at last I used this code (&#xD;) it works now, but story Editor doesn't look good. thank you anyway.
    – HamiD
    Commented Jun 17, 2019 at 14:41
  • I think the problem you are having might be because of the text editor you are using. Try using one that can recognise XML formatting, for example: Notepad++.
    – Billy Kerr
    Commented Jun 17, 2019 at 16:08

1 Answer 1


If it is xml this is actually the right way. Contrary to html-documents, whitespaces you get from formatting xml-documents are often causing problems in the further processing. They are actual spaces which are in the code. XSLT-trasformation will process these spaces and the output will be buggy. Read here for a more detailed explanation: https://www.oracle.com/technetwork/articles/wang-whitespace-092897.html

If you want to look at it in a formatted way, most xml-editors f.e. Oxygen offer an option to format the code. But it will put the whitespace in there so you should use this button only to look at it an never save it. If you want to edit the code you'll need to go through it without it being formatted.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.