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

ASP.NET
asp+的页面指示标识
亲密接触ASP+(1)
亲密接触ASP+(2)
使用纯粹的asp+语言制作的栏目管理(二)
使用纯粹的asp+语言制作的栏目管理(三)
利用asp+的独特的底层操作的功能实现对Pop服务器的存取(实现了asp+收pop信件的功能)
C#中的函数重载
开发者面临的.Net挑战(二)
ASP中是如何使用存储过程的
深入讲解 ASP+ 验证(一)
深入讲解 ASP+ 验证(二)
深入讲解 ASP+ 验证(三)
深入讲解 ASP+ 验证(四)
ASP.NET强大的性能(一)
ASP.NET强大的性能(二)
ASP.NET多语言支持
ASP.NET升级能力探讨(一)
ASP.NET升级能力探讨(二)
ASP.NET升级能力探讨(三)
ASP.NET超凡的代码控制(一)

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


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

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