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

ASP
提高SQL的执行效率的ASP的五种做法
asp的offset的一个go to page
asp中command的在单条记录时,有些字段显示为空的问题
asp,php一句话木马整理方便查找木马
asp 合并记录集并删除的sql语句
asp下循环一行多少个
asp循环行数输出函数
asp access重新开始编号
ASP生成数字相加求和的BMP图片验证码
静态页面利用JS读取cookies记住用户信息
比较详细的Asp伪静态化方法及Asp静态化探讨
asp Response.flush 实时显示进度
Asp高级故障解决以及相关代码
asp智能脏话过滤系统v1.0
ASP文件中的安全问题
Access数据库中“所有记录中均未找到搜索关键字”的解决方法
asp两组字符串数据比较合并相同数据
asp MYSQL出现问号乱码的解决方法
asp文章中随机插入网站版权文字的实现代码
ASP利用XMLHTTP实现表单提交以及cookies的发送的代码

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 103 ::
收藏到网摘: 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>
  
  这个功能和上面的一样,我在这儿就不多说了。
  待续。。。