xml version="1.0" encoding="utf-8"
?>
<
xsl:stylesheet
version
="1.0"
xmlns:xsl
="http://www.w3.org/1999/XSL/Transform"
>
<
xsl:param
name
="strNewsId"
/>
<
xsl:template
match
="/"
>
<
html
>
<
body
>
<
FONT
face
="Verdana"
size
="3"
>
<
TABLE
cellspacing
="5"
cellpadding
="1"
>
<
TR
bgcolor
="#AAAAAA"
>
<
TD
class
="header"
>
<
B
>
评论内容
B
>
TD
>
<
TD
class
="header"
>
<
B
>
发表时间
B
>
TD
>
TR
>
<
xsl:for-each
select
="//AllComment/Comment[@NewsId=$strNewsId]"
>
<
xsl:sort
select
="AddTime"
order
="descending"
/>//倒序排序
<
TR
bgcolor
="#DDDDDD"
>
<
TD
>
<
xsl:value-of
select
="CommentContent"
/>
TD
>
<
TD
>
<
xsl:value-of
select
="AddTime"
/>
TD
>
TR
>
xsl:for-each
>
TABLE
>
FONT
>
<!--
This is an XSLT template file. Fill in this area with the XSL elements which will transform your XML to XHTML.
-->
body
>
html
>
xsl:template
>
xsl:stylesheet
>
using
System;
using
System.Data;
using
System.Configuration;
using
System.Collections;
using
System.Web;
using
System.Web.Security;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
System.Web.UI.WebControls.WebParts;
using
System.Web.UI.HtmlControls;
using
System.Xml;
using
System.Xml.Xsl;
using
System.Xml.XPath;
public
partial
class
NewsFiles_DisplayComment : System.Web.UI.Page ...{ protected void Page_Load(object sender, EventArgs e) ...{ string NewsId = Request.QueryString["NewsId"].ToString().Trim(); XPathDocument xmlDoc = new XPathDocument(Server.MapPath("../XmlFiles/Comment.xml")); XslTransform xmlTrans = new XslTransform(); xmlTrans.Load(Server.MapPath("../XmlFiles/Comment.xsl")); XsltArgumentList xsltArgList = new XsltArgumentList(); xsltArgList.AddParam("strNewsId", "", NewsId); Response.ContentType = "text/html"; xmlTrans.Transform(xmlDoc, xsltArgList, Response.OutputStream); } }