News Update System Using asp.net and xml (2)

Source: Internet
Author: User
Tags xslt

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...

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.