Those two fragments are definitely not the same. XML does not mean 'ignore all whitespace'.
In other words line endings are not formatting but content!!
That they are ignored by users (i.e. programs/applications) of an XML document is something completely different. (Or removed explicitely for example when defining XSLT transformations.)
I don't disagree with what you are saying, just trying to figure out how XML is working. I did a little more research and it looks like, within tags, end of lines are stored as line feeds. Between tags, end of lines may be lost. So if the OP was using Windows, what the OP might have been seeing is:
<tag1>
<tag2>
Some text#13#10
</tag2>
</tag1
converted as
<tag1><tag2>Some text#10</tag2></tag1>
Since CR/LF is not LF, whatever the OP was using to view the XML file may not have displayed the text correctly (as in using notepad).
But that is only if the OP was using Windows. Obviously, this would not be the same issue in Linux.
Of course the issue may be with the writer not writning correctly unless CDATA is used. I haven't looked at the code to see what it is doing. I just know CDATA solved my problem when I ran into the same thing.