簡體   English   中英

在 XML 中使用制表符而不是空格縮進

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

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM