如何在XmlTextWriter中使用CR而不是CRLF生成XML [英] How can I generate XML with CR, instead of CRLF in XmlTextWriter
问题描述
我正在通过XmlTextWriter生成XML.
I'm generating XML via XmlTextWriter.
该文件在我看来不错,可以进行验证(在wc3上进行 ),然后被客户接受了.
The file looks good to my eyes, validates (at wc3), and was accepted by the client.
但是客户供应商抱怨行尾是CRLF,而不仅仅是CR.
But a client vendor is complaining that the line-endings are CRLF, instead of just CR.
好吧,我在使用C#的Win32机器上,CRLF是Win32标准的行尾. 有什么方法可以更改XmlTextWriter中的行尾吗?
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?
还-行尾对适当的XML解析器不重要吗?
Also -- shouldn't the line-endings not matter to a proper XML parser?
另请参阅:什么是回车符,换行符和换页符?
注意:唯一的答案似乎是一个横向解决方案-您必须使用XmlWriter而不是XmlTextWriter
NOTE: looks like the only answer is a sideways solution -- you have to use the XmlWriter instead of the XmlTextWriter
推荐答案
当然,问了一下之后,我在MSDN上找到了一条线索(我无法通过google找到),该线索指向
of course, moments after asking, I find a clue on MSDN (that I couldn't find via google) that refers to XmlWriterSettings.NewLineChars
然后,我在全部在术语中.....
It's all in the terminology.....
这篇关于如何在XmlTextWriter中使用CR而不是CRLF生成XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!