1.今天做项目时候生成XML文件,有些节点是为空节点,但是生成之后的节点自动换行了,网上百度了一下,大都是设置添加属性为xsi:nil="true"的空节点。
http://www.acehat.com/kf/201503/78602.html
但是本人太笨不会用,于是又找到另一种方法,即为:
1 XmlWriterSettings settings = new XmlWriterSettings(); 2 settings.Indent = true; 3 settings.IndentChars = " "; 4 settings.Encoding = Encoding.UTF8; 5 using (XmlWriter xmlWriter = XmlWriter.Create(xmlFileName, settings)) 6 { 7 xmldoc.Save(xmlWriter); 8 }
时间: 2024-10-13 10:58:02