C#简单的写入xml文件的方法
StringWriter stringWriter = new StringWriter(); XmlTextWriter xmlTextWriter = new XmlTextWriter(stringWriter); xmlTextWriter.Formatting = Formatting.Indented; xmlDocument.WriteTo(xmlTextWriter); //xmlDocument can be replaced with an XmlNode xmlTextWriter.Flush(); Console.Write(stringWriter.ToString());