[英]Indent with tabs instead of spaces in XML
好的,所以我有一些代码应该更改配置文件中的值。
string xmlFile = "KeePass.config.xml";
System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
XmlWriterSettings settings = new XmlWriterSettings();
settings.IndentChars = "\t";
settings.Indent = true;
xmlDoc.Load(xmlFile);
xmlDoc.SelectSingleNode("Configuration/Application/LastUsedFile").InnerText = fileName;
xmlDoc.Save(xmlFile);
这样做的问题是它使用空格而不是制表符缩进 XML 文件,并且读取配置文件的程序需要查看带有制表符缩进的 XML。 任何帮助,将不胜感激。
你有没有尝试过
xmlDoc.PreserveWhitespace = true;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.