Here I will use XML to replace data and write a news and publishing system. I hope this will help more people understand the latest technologies. These files are described below. Contents. xml <? XML version = "1.0" encoding = "gb2312"?> <Topiclist type = "aspcool News"> <Topic> <Title> aspcool news! </Title> <Href> main. aspx? Name = Hello </Topic> <Topic> <Title> resolve a problem </title> <Href> main. aspx? Name = test </Topic> </Topiclist> This is a simple XML file used to display the news list. Hello. xml <? XML version = "1.0" encoding = "gb2312"?> <Document> <Title> aspcool news! </Title> <ABSTRACT> test news </abstract> <Author> feiying </author> <Content> <Paragraph> the firet test </Paragraph> </Content> </Document> This document is used to display news content. The meaning of this document is clearly understood and I will not talk about it here. The following is a page for you to view the news list. News. aspx <% @ Import namespace = "system" %> <% @ Page Language = "C #" DEBUG = "true" codePage = "936" %> <% @ Import namespace = "system. Io" %> <% @ Assembly name = "system. xml" %> <% @ Import namespace = "system. xml" %> <% @ Import namespace = "system. xml. XSL" %> <HTML> <Head> <Title> </Title> <Script language = "C #" runat = "server"> Public String XSLT () { Stringwriter writer = new stringwriter (); // Load the XML Object Xmldocument xmldoc = new xmldocument (); Xmldoc. Load (server. mappath ("contents. xml ")); // Load the XSL object Using transform Doc = new using transform (); Using Doc. Load (server. mappath ("news. XSL ")); // Convert XML into HTML pages Documentnavigator nav = new documentnavigator (xmldoc ); Using Doc. Transform (NAV, null, writer ); Return writer. tostring (); } </SCRIPT> </Head> <Body> <% = XSLT () %> <P align = "center"> The Program Designed and created by <a href = "www. aspcool. comhttp: // www.aspcool.com"> www.aspcool.com </a>. </P> </Body> </Html> This page has been converted from XML to HTML files through XSLT, and I have a better understanding of XSLT. The following is a page showing the news: Main. aspx <% @ Import namespace = "system" %> <% @ Page Language = "C #" DEBUG = "true" codePage = "936" %> <% @ Import namespace = "system. Io" %> <% @ Assembly name = "system. xml" %> <% @ Import namespace = "system. xml" %> <% @ Import namespace = "system. xml. XSL" %> <HTML> <Head> <Title> </Title> <Script language = "C #" runat = "server"> Public String XSLT () { Stringwriter writer = new stringwriter (); Xmldocument xmldoc = new xmldocument (); Xmldoc. Load (server. mappath (request ["name"] + ". xml ")); Using transform Doc = new using transform (); Using Doc. Load (server. mappath ("Main. XSL ")); Documentnavigator nav = new documentnavigator (xmldoc ); Using Doc. Transform (NAV, null, writer ); Return writer. tostring (); } </SCRIPT> </Head> <Body> <% = XSLT () %> <P align = "center"> This program is designed and manufactured by <a href = "www. aspcool. comhttp: // www.aspcool.com"> www.aspcool.com </a>. </P> </Body> </Html> This function is the same as above. I will not talk about it here. Finally, let's take a look at the most responsible page. This page is used to create new XML data. Manage. aspx <% @ 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" %> <HTML> <Head> <Script language = "C #" runat = "server"> 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 (); } Else { Xmlnode currnode; Xmldocument xmldoc = new xmldocument (); Xmldoc. Load (server. mappath ("contents. xml ")); String insstr = "<topic> <title>" + textbox2.text + "</title> Main. aspx? Name = "+ textbox1.text +" Xmldocumentfragment docfrag = xmldoc. createdocumentfragment (); Docfrag. innerxml = insstr; Currnode = xmldoc. documentelement; Currnode. insertafter (docfrag, currnode. lastchild ); // Save the output to a file Xmldoc. Save (server. mappath ("contents. xml ")); // 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 ("\ n", "</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 = ""; } // Write data to the directory file } 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: pixel; 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> name = button2 runat =" server "onserverclick =" button2_click "designtimedragdrop =" 59 ">
runat =" server "id =" button1 "name =" Bu Tton1 "style =" Z-INDEX: 112; left: 268px; position: absolute; top: export PX "> this program is in. net beta2 build 9148 passed the test. |