xmlreader newline \n instead of \r\n

后端 未结 5 1002
天命终不由人
天命终不由人 2021-01-11 11:21

When I use XmlReader.ReadOuterXml(), elements are separated by \\n instead of \\r\\n. So, for example, if I have XmlDocument representatino of


<         


        
5条回答
  •  别那么骄傲
    2021-01-11 11:35

    XmlReader will automatically normalize \r\n\ to \n. Although this seems unusual on Windows, it is actually required by the XML Specification (http://www.w3.org/TR/2008/REC-xml-20081126/#sec-line-ends).

    You can do a String.Replace:

    string s = reader.ReadOuterXml().Replace("\n", "\r\n");
    

提交回复
热议问题