元ネタ:XMLDocumentのLoadメソッドに置けるタブ、改行について - Insider .NET会議室
Load や LoadXml の呼出前に、XmlDocument.PreserveWhitespace プロパティ (System.Xml) を true に設定します。
using System; using System.Xml; class Program { static void Main(string[] args) { XmlDocument doc = new XmlDocument(); doc.Load("./XMLFile1.xml"); Console.WriteLine(doc.InnerXml); doc = new XmlDocument(); doc.PreserveWhitespace = true; doc.Load("./XMLFile1.xml"); Console.WriteLine(doc.InnerXml); Console.ReadKey(); } }