1. XmlTextWriter indicates the writer that provides a fast, non-cached, and only-in method. This method generates XML data (the data conforms to W3C Extensible Markup Language (XML) 1.0 and "namespace in XML" are recommended) streams or files. Public class XmlTextWriter: XmlWriter XmlTextWriter inherits the abstract class XmlWriterXmlTextWriter. Example: string resultFileName = "c:/44.txt"; if (! System. IO. directory. exists (System. IO. path. getDirectoryName (resultFileName) {System. IO. directory. createDirectory (System. IO. path. getDirectoryName (resultFileName);} XmlTextWriter result = new XmlTextWriter (resultFileName, null); result. formatting = Formatting. indented; result. writeStartElement ("PolicyList"); result. writeStartElement ("Policy"); result. writeAttributeString ("username", "USERNAME" + I. ToString (); result. writeEndElement (); result. writeEndElement (); result. close (); XmlTextWriter does not cause memory overflow because it writes data to the hard disk as a stream. 2. I made a comparison between XmlTextWriter and common concatenated characters: XmlTextWriter string resultFileName = "c:/44.txt"; if (! System. IO. directory. exists (System. IO. path. getDirectoryName (resultFileName) {System. IO. directory. createDirectory (System. IO. path. getDirectoryName (resultFileName);} XmlTextWriter result = new XmlTextWriter (resultFileName, null); result. formatting = Formatting. indented; result. writeStartElement ("PolicyList"); for (int I = 0; I <100000000; I ++) {result. writeStartElement ("Policy"); result. writeAtt RibuteString ("username", "USERNAME" + I. toString (); result. writeEndElement ();} result. writeEndElement (); result. close (); normal: XmlDocument xmlD = new XmlDocument (); StringBuilder sb = new StringBuilder (); for (int I = 0; I <100000000; I ++) {sb. append ("<PolicyList username = 'username" + I. toString () + "'/>");} xmlD. loadXml (sb. toString (); StreamWriter sw = new StreamWriter ("c:/55.txt"); sw. write ("www" ); Sw. Close (); the first is displayed normally, and the second is displayed with a memory overflow prompt. Therefore, when the data volume is large. It must be written as a stream to prevent memory overflow. 3. This reminds me of the fact that we did not think about writing data to the hard disk when we used. net to write the output. If memory overflow occurs, it is not feasible. In fact, I did not really want to talk about writing data to the hard disk? Wrong. I thought of it. But I immediately deny myself. I always feel that this is impossible. This is the limitation of thinking. My thinking is limited. Later I thought. net is actually a framework. All the things that can be implemented by binary assembly can also be implemented by advanced languages. A computer is nothing more than a binary operation. It can write data to the memory, or write data to the hard disk. After all, we are doing this kind of thing every day. Just ignore it. So I want to break my mind limitations and boldly imagine it!