henrikx
henrikx

Reputation: 23

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.

Upvotes: 2

Views: 2878

Answers (1)

ʃʈɑɲ
ʃʈɑɲ

Reputation: 2694

Have you tried

xmlDoc.PreserveWhitespace = true;

Upvotes: 4

Related Questions