简体   繁体   中英

Indent with tabs instead of spaces in XML

Okay so I have some code which is supposed to change a value in a configuration file.

        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);

The problem with this is that it indents the XML file with spaces instead of tabs and the program which reads the configuration file needs to see the XML with tab indents. Any help would be appreciated.

你有没有尝试过

xmlDoc.PreserveWhitespace = true;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM