LINQ to XML ignores line breaks in attributes

Viewed 1484

According to this question:

Are line breaks in XML attribute values allowed?

line breaks in XML attributes are perfectly valid (although perhaps not recommended):

<xmltag1>
    <xmltag2 attrib="line 1
line 2
line 3">
    </xmltag2>
</xmltag1>

When I parse such XML using LINQ to XML (System.Xml.Linq), those line breaks are converted silently to space ' ' characters.

Is there any way to tell the XDocument.Load() parser to preserve those line breaks?

P.S.: The XML I'm parsing is written by third-party software, so I cannot change the way the line breaks are written.

3 Answers
Related