This is an easy way of formatting an XmlDocument into an indented string. Could be useful for logging, etc?
XmlDocument doc = ...; ... StringWriter sw = new StringWriter(); XmlTextWriter xtw = new XmlTextWriter(sw); xtw.Formatting = Formatting.Indented; doc.WriteTo(xtw); Console.WriteLine(sw.ToString());