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 (); </P> <P>}
</Script>
</Head>
<Body>
<% = Xslt () %>
<P align = "center"> This program is designed and manufactured by <a href = "http://www.aspcool.com"> www.aspcool.com </a>. </p> </P> </body>
</Html> </P> <P> This page completes the conversion from xml to html files through xslt, which gives me a better understanding of xslt. </P> <P> The following is the page on which news content is displayed:
Main. aspx </P> <% @ 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 (); </P> <P> XmlDocument xmldoc = new XmlDocument ();
Xmldoc. Load (Server. MapPath (Request ["name"] + ". xml"); </P> <P> convert transform into Doc = new transform ();
Export Doc. Load (Server. MapPath ("main. xsl"); </P> <P> DocumentNavigator nav = new DocumentNavigator (xmldoc );
Using Doc. Transform (nav, null, writer );
Return writer. ToString (); </P> <P>}
</Script>
</Head>
<Body>
<% = Xslt () %>
<P align = "center"> This program is designed and manufactured by <a href = "http://www.aspcool.com"> www.aspcool.com </a>. </p> </P> </body>
</Html> </P> <P> this function is the same as above. I will not talk about it here.
To be continued...