Finally, let's take a look at the most responsible page. This page is used to create new xml data.
Manage. aspx </P> <% @ Import Namespace = "System. Xml. Xsl" %>
<% @ Import Namespace = "System. Xml" %>
<% @ Assembly Name = "System. Xml" %>
<% @ Import Namespace = "System. IO" %>
<% @ Page Language = "C #" Debug = "true" codepage = "936" %>
<% @ Import Namespace = "System" %> </P> <HTML>
<HEAD>
<Script language = "C #" runat = "server"> </P> <P> public void button#click (object sender, System. EventArgs e)
{
// Determine whether a file exists
If (File. Exists (Server. MapPath (TextBox1.Text + ". xml ")))
{
Response. Write ("the file name already exists. Please reselect the file name. ");
Response. End (); </P> <P>}
Else
{</P> <P> XmlNode currNode;
XmlDocument xmldoc = new XmlDocument ();
Xmldoc. load (Server. mapPath ("contents. xml "); </P> <P> string InsStr =" <topic> <title> "+ TextBox2.Text +" </title> XmlDocumentFragment docFrag = xmldoc. CreateDocumentFragment ();
DocFrag. InnerXml = InsStr; </P> <P> currNode = xmldoc. DocumentElement;
CurrNode. InsertAfter (docFrag, currNode. LastChild );
// Save the output to a file
Xmldoc. Save (Server. MapPath ("contents. xml"); </P> <P> // Replace the file in TextBox5 with the content in xml format.
String xmlfile = TextBox5.Text. Replace ("&","&");
Xmlfile = xmlfile. Replace ("<", "<");
Xmlfile = xmlfile. Replace (">", "> ");
Xmlfile = xmlfile. Replace (@"""""",""");
Xmlfile = xmlfile. Replace ("", "& apos ;");
Xmlfile = xmlfile. Replace ("", "</paragraph> <paragraph> ");
// Write data to the new xml file.
XmlDocument doc = new XmlDocument ();
Doc. LoadXml ("<? Xml version = 1.0 encoding = GB2312?> <Document> <title> "+ TextBox2.Text +" </title> <abstract> "+ TextBox4.Text +" </abstract> <author> "+ TextBox3.Text +" </author> <content> <paragraph> "+ xmlfile +" </paragraph> </content> </document> ");
Doc. Save (Server. MapPath (TextBox1.Text + ". xml "));
Response. Write ("You hava input the article! ");
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
TextBox5.Text = ""; </P> <P >}</P> <P>
// Write data to the directory file </P> <P>}
Public void Button2_Click (object sender, System. EventArgs e)
{}
</Script>
<Meta content = "Internet Explorer 5.0" name = vs_targetSchema>
<Meta content = "Microsoft Visual maxcompute 7.0" name = GENERATOR>
<Meta content = C # name = CODE_LANGUAGE>
</HEAD>
<Body MS_POSITIONING = "GridLayout">
<Form runat = "server">
<FONT face =>
<Asp: label id = Label1 style = "Z-INDEX: 100; LEFT: 230px; POSITION: absolute; TOP: 27px "runat =" server "Height =" 28px "Width =" 156px ">
Asp cool Technology Information Network website content publishing system
</Asp: label>
<Asp: label id = Label2 style = "Z-INDEX: 101; LEFT: 110px; POSITION: absolute; TOP: 68px "runat =" server "Height =" 25px "Width =" 65px ">
File Name:
</Asp: label>
<Asp: textbox id = TextBox1 style = "Z-INDEX: 102; LEFT: 255px; POSITION: absolute; TOP: 64px "runat =" server "Height =" 33px "Width =" 178px ">
</Asp: textbox>
<Asp: label id = Label3 style = "Z-INDEX: 103; LEFT: pixel; POSITION: absolute; TOP: 126px "runat =" server "Height =" 36px "Width =" 86px ">
Article Name:
</Asp: label>
<Asp: textbox id = TextBox2 style = "Z-INDEX: 104; LEFT: 256px; POSITION: absolute; TOP: 114px "runat =" server "Height =" 37px "Width =" 177px ">
</Asp: textbox>
<Asp: label id = Label4 style = "Z-INDEX: 105; LEFT: 114px; POSITION: absolute; TOP: 183px "runat =" server "Height =" 31px "Width =" 89px ">
Author:
</Asp: label>
<Asp: textbox id = TextBox3 style = "Z-INDEX: 106; LEFT: 256px; POSITION: absolute; TOP: 183px "runat =" server "Height =" 36px "Width =" 179px ">
</Asp: textbox>
<Asp: label id = Label5 style = "Z-INDEX: 107; LEFT: 114px; POSITION: absolute; TOP: 241px "runat =" server "Height =" 51px "Width =" 81px ">
Abstract:
</Asp: label>
<Asp: textbox id = TextBox4 style = "Z-INDEX: 108; LEFT: 256px; POSITION: absolute; TOP: 245px "runat =" server "Height =" 36px "Width =" 179px ">
</Asp: textbox>
<Asp: label id = Label6 style = "Z-INDEX: 109; LEFT: margin PX; POSITION: absolute; TOP: 315px "runat =" server "Height =" 36px "Width =" 78px ">
Content:
</Asp: label>
<Asp: textbox id = TextBox5 style = "Z-INDEX: 110; LEFT: 259px; POSITION: absolute; TOP: 303px "runat =" server "Height =" 95px "Width =" 252px "textmode =" MultiLine ">
</Asp: textbox>
</FONT> </P> <INPUT id = Button2 style = "Z-INDEX: 113; LEFT: 343px; WIDTH: 40px; POSITION: absolute; TOP: pixel PX; HEIGHT: 24px "type = button value = reset name = Button2 runat =" server "OnServerClick =" Button2_Click "DESIGNTIMEDRAGDROP =" 59 ">
<Br>
<Br>
<Div id = mess runat = server>
</Div>
<Br>
<Input type = "button" value = "Submit" OnServerClick = "button#click" runat = "server" ID = "Button1" NAME = "Button1" style = "Z-INDEX: 112; LEFT: 268px; POSITION: absolute; TOP: pixel ">
</Form>
</Body>
</HTML>
This program passed the test in. net beta2 build 9148.