tags:

views:

514

answers:

1

I created following simple xml (C escape sequence used) "<A>\n</A>" When MSXML (v4 and v6) serialize DOM document using IXMLDOMDocument2.xml it changes newline to dos format and returns: "<A>\r\n</A>" instead.

When I use DOM to retrieve only string node inside element I get correct single character ("\n") string.

Of course I have preserveWhiteSpaceset to VARIANT_TRUE

XML.Net and Xerces parsers works fine and do not modify the stored string while serializing the xml document.

Is that a bug in msxml? any idea?

thx Jiri

A: 

Microsoft changed the way that newline serialization is handled in MSXML 4 onwards to comply with the w3wc standards (See http://support.microsoft.com/kb/261293)

I have no idea why the same wasn't done for for the xml implementation in .Net, but the same is done for web services in .Net 2.0.

When I had this problem last I came to the conclusion that you either need to account for the fact that newline characters may be serialised unpredictably (for example by replacing \r\n with \n), or you need to base-64 encode your text (or equivalent)

Kragen