根据Erika Ehrli的博客改编而成,应该这样做:XmlDocument doc = new XmlDocument();doc.LoadXml("<item><name>wrench</name></item>");// Save the document to a file and auto-indent the output.using (XmlTextWriter writer = new XmlTextWriter("data.xml", null)) { writer.Formatting = Formatting.Indented; do