Skip to content
Advertisement

Carriage return symbol is removed from XML using OPENXML

It looks like SQL Server removes r characters when parsing XML. So when my stored procedure receives values in xml for saving, all line breaks are represented as n instead of rn.

Is there any way I can force SQL Server to not remove r characters? In the sample below Node1 value doesn’t contain r symbols.

Output:
enter image description here

@PJB suggested to use XQuery nodes instead. But this doesn’t helps. I tried to run query below and got the same result.

Advertisement

Answer

Carriage return symbol is removed from XML

This is the correct behavior according the XML spec on End-of-Line Handling.

the XML processor MUST behave as if it normalized all line breaks in external parsed entities (including the document entity) on input, before parsing, by translating both the two-character sequence #xD #xA and any #xD that is not followed by #xA to a single #xA character.

You could try to use a replace to get the carriage-return back.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement