C # operation XML preliminary (3) Chapter 1: New XML file below is an example of XML through a DataSet <% @ Import namespace = "system.io"%>
<% @ Import namespace = "system.xml"%>
<% @ Import namespace = "system.data"%>
Public void Page_Load (Object SRC, Eventargs E)
{
/ *
* Copyright by SEM IT Department
* Version: Version 0.0.1
* Document: CreateXML_3.ASPX
* Used: Use a data set to establish an XML file.
* Author: Ouyang Yuntian @ 2005-4-7
* Mailbox: Outrace@soueast-motor.com
* Repair:
* /
String fromfile; // Template file
String newfile;
Fromfile = server.mappath ("./") " template.xml ";
Newfile = server.mappath ("./") " new.xml ";;
DataSet myds = new dataset ();
FileStream Fin;
FIN = New filestream (fromFile, Filemode.open, FileAccess.Read, Fileshare.Readwrite);
myds.readxml (fin);
Fin.close ();
/ / Here we use the Dataset, which is obtained from XML, of course, we can also get DataSet from the database, array, etc. and generate XML.
Myds.writexml (NewFile, XMLWRITE.WRITESCHEMA);
myds.dispose ();
// read XML in XML DOM and bind it with XML control
XmLDocument Doc = New XmLDocument ();
Doc.Load (newfile);
XML1.Document = DOC;
}
Catch (Exception EX)
{
Response.write (ex.Message);
}
Finally
{
}
}
script>
hEAD>