当前位置: 首页 > 图文教程 > 网络编程 > ASP > 用asp.net和xml做的新闻更新系统(2)

ASP
如何把ASP编写成DLL(3)
ASP实用大全-实战ASP(1)
ASP实用大全-实战ASP(2)
ASP实用大全-实战ASP(3)
ASP实用大全-实战ASP(4)
ASP实用大全-实战ASP(5)
ASP实用大全-实战ASP(6)
ASP实用大全-实战ASP(7)
ASP实用大全-实战ASP(8)
ASP中Cookie使用指南
Flash和Asp数据库的结合应用
asp模块化分页制作详解
ASP中使用SQL语句操作数据库
浅谈ASP中Web页面间的数据传递
一个采集入库生成本地文件的几个FUCTION
微软建议的ASP性能优化28条守则(1)
微软建议的ASP性能优化28条守则(2)
微软建议的ASP性能优化28条守则(3)
微软建议的ASP性能优化28条守则(4)
微软建议的ASP性能优化28条守则(5)

ASP 中的 用asp.net和xml做的新闻更新系统(2)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 38 ::
收藏到网摘: n/a

      
  作者:飞鹰 版权归www.aspcool.com所有,转载时请保留此信息。
  
  下面给大家看新闻列表显示的页面。
  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();
  //装入xml对象
  XmlDocument xmldoc= new XmlDocument();
  xmldoc.Load(Server.MapPath("Contents.xml"));
  //装入xsl对象
  XslTransform xsldoc = new XslTransform();
  xsldoc.Load(Server.MapPath("news.xsl"));
  //把xml转化成html页面
  DocumentNavigator nav= new DocumentNavigator(xmldoc);
  xsldoc.Transform(nav,null,writer);
  return writer.ToString();
  
  }
  </script>
  </head>
  <body>
  <%=xslt()%>
  <p align="center">该程序由<a href="http://www.aspcool.com">www.aspcool.com</a>设计制作.</p>
  
  </body>
  </html>
  
  这个页面完成了从xml通过xslt转化成html文件,也使我对于xslt有了进一步的认识。
  
  下面是新闻内容显示的页面:
  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"));
  
  XslTransform xsldoc = new XslTransform();
  xsldoc.Load(Server.MapPath("main.xsl"));
  
  DocumentNavigator nav= new DocumentNavigator(xmldoc);
  xsldoc.Transform(nav,null,writer);
  return writer.ToString();
  
  }
  </script>
  </head>
  <body>
  <%=xslt()%>
  <p align="center">该程序由<a href="http://www.aspcool.com">www.aspcool.com</a>设计制作.</p>
  
  </body>
  </html>
  
  这个功能和上面的一样,我在这儿就不多说了。
  待续。。。