C # operation XML preliminary (1) Chapter 1: New XML file new XML file has different methods, I give three ways here <% @ Import namespace = "system.io"%>
Public void Page_Load (Object SRC, Eventargs E)
{
/ *
* Copyright by SEM IT Department
* Version: Version 0.0.1
* Document: CREATEXML_1.ASPX
* Use the way: Create an XML file we can use a text text to create a new XML file
* Author: Ouyang Yuntian @ 2005-4-7
* Mailbox: Outrace@soueast-motor.com
* Repair:
* /
String filename;
FileName = "Users_1.xml";
// Establish StreamWrite, please note that you set your own file directory here.
StreamWriter RW = file.createtext (Server.Mappath (".") "// files //" filename);
// Write the content using WriteLine
Rw.writeLine (" XML Version = /" 1.0 / "encoding = /" GB2312 / "?>");
Rw.writeLine ("
rw.writeLine ("
Rw.writeLine ("
Rw.writeline ("
rw.writeLine (" user>");
Rw.writeLine ("
RW.Writeline ("
Rw.writeline ("
rw.writeLine (" user>");
Rw.writeLine (" users>");
/ / Write the contents of the buffer into the file
Rw.flush ();
// Turn off the RW object
Rw.close ();
// Open the text file
StreamReader SR = file.opentext (Server.MAppath (".") "// files //" filename);
// When using a character connection, C # recommends using StringBuilder instead of using the " " character.
// I heard that this will be a lot faster, but I haven't tested it.
Stringbuilder output = new stringbuilder ();
String rl;
While ((rl = sr.readline ())! = NULL)
{
Output.Append (rl "
);
}
LBLFILE.TEXT = OUTPUT.TOSTRING ();
sr.close ();
}
script>
hEAD>