Line ending interpretation

Separate lines of text are often found in XML documents, and indeed in other text-based document formats. Text may be broken into lines for various reasons; either for convenience, or to signify and isolate important sub-units of information. Either way, the presence of multiple text lines can also cause complications.

Line-end codes

The points at which line-end codes appear may have been carefully chosen to avoid corrupting the text. It is possible to interpret line-end codes in three ways. The line-end code can:

  • be retained, and used to force a line-break when presented

  • be removed

  • be replaced by a space.

These interpretations can be illustrated with three examples:

<software>10 PRINT "Hello World"[CR] 20 GOTO 10.</software> ...

Get XML Companion, The, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.