问题:XML的一个字符串:“我爱 \r\n 大中国”把这个字符串读入到C#中输出,换行就是失败了,但是如果直接把这段话放到程序里,就可以换行

 

解决办法:将字符串\\r\\n 替换为C#识别的换行符

XmlDocument doc = new XmlDocument();
doc.Load(@"G:\test.xml");
String x = doc.SelectSingleNode("//root").InnerText;
x = x.Replace("\\r\\n", Environment.NewLine);

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-06-22
  • 2022-03-02
  • 2021-10-01
  • 2021-12-08
  • 2022-02-12
  • 2022-12-23
猜你喜欢
  • 2021-06-09
  • 2022-12-23
  • 2021-08-30
  • 2021-10-18
  • 2021-12-18
  • 2022-12-23
相关资源
相似解决方案