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

后端 未结 4 1509
故里飘歌
故里飘歌 2021-01-19 17:57

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 complainin

4条回答
  •  無奈伤痛
    2021-01-19 18:41

    Use the XmlWriterSettings to set what you want as your end of line char.

    XmlWriterSettings mySettings = new XmlWriterSettings();
    mySettings.NewLineChars = "\r";
    
    XmlWriter writer = XmlWriter.Create(
                             new StreamWriter(@"c:\temp\hello.xml", mySettings);
    

    I don't know where end of line characters would matter. I haven't run into it before.

提交回复
热议问题