Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I generate XML with CR, instead of CRLF in XmlTextWriter

I'm generating XML via XmlTextWriter.

The file looks good to my eyes, validates (at wc3), and was accepted by the client.

But a client vendor is complaining that the line-endings are CRLF, instead of just CR.

Well, I'm on a Win32 machine using C#, and CRLF is the Win32 standard line-ending. Is there any way to change the line-endings in the XmlTextWriter?

Also -- shouldn't the line-endings not matter to a proper XML parser?

see also: What are carriage return, linefeed, and form feed?

NOTE: looks like the only answer is a sideways solution -- you have to use the XmlWriter instead of the XmlTextWriter

like image 640
Michael Paulukonis Avatar asked Dec 17 '22 22:12

Michael Paulukonis


1 Answers

of course, moments after asking, I find a clue on MSDN (that I couldn't find via google) that refers to XmlWriterSettings.NewLineChars

which then led me to the unaccepted answer on SO: Writing XMLDocument to file with specific newline character (c#)

It's all in the terminology.....

like image 95
Michael Paulukonis Avatar answered Jan 31 '23 00:01

Michael Paulukonis