[英]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.