Line Break Handling in Specific Programs
For the vast majority of programs then, the normalized '/n' line break in XML files should be correctly interpreted. This is certainly the case in C# and Java. As a quick aside, if you are programmatically generating XML files in C# I would highly recommend reading Microsoft's article on indenting XML files using XmlDocument or XSL Transforms.
There are, of course, a number of programs that aren't quite so nice; Flash and ActionScript are two notorious culprits for messing up line breaks. One way to get around Flash's distaste for whitespace characters is to make use of 'ignoreWhite' when loading an XML document:
var objectName = new XML();
objectName.ignoreWhite = true;
This will often fix weird formatting issues, such as double spaced line breaks. If you find that Flash isn't rendering line breaks in your XML file at all, then CDATA tags may be the solution. These allow embedding of HTML tags within an XML node, and can be used specifically to embed the <br> html line break character, like so:
<xmlNode><![CDATA[first line<br/>second line<br/>]]></xmlNode>
When dealing with Flash, using character entity references is also a valid tactic. Characters like '
' get ignored by the initial Flash parser, and hence displayed properly when parsed by the browser.
Moving away from Flash, PHP is another language that sometimes has issues properly display newline characters. When outputting data from an XML document into HTML you might find it useful to make use of the 'nl2br' function, which inserts HTML line breaks before every newline character.