繁体中文
设为首页
加入收藏
当前位置:.Net技术首页 >> Asp.Net开发 >> ASP.NET XML/XSL Transforms(转载www.aspalliance.com)

ASP.NET XML/XSL Transforms(转载www.aspalliance.com)

2007-06-15 08:00:00  作者:  来源:互联网  浏览次数:0  文字大小:【】【】【
简介:Transforming an XML document using XSL/T and outputting the results to the browser is a fairly simple task in ASP.NET. The following user control demonstrates the ease with which this can be accom...

Transforming an XML document using XSL/T and outputting the results to the browser is a fairly simple task in ASP.NET. The following user control demonstrates the ease with which this can be accomplished. This user control has a parameter for the XML source(XMLSource), and a parameter for the XSL source(xslSource). When placing this user control on a page, simply specify both values (using relative paths, since they are Server.MapPath'ed within the user control) and you're done! The transformed result will be output to Response.Output and sent to the user's browser. You can use this to create a two line ASPX file that simply uses this user control to render its output. By using Output and/or Fragment caching, you can ensure that the CPU load required to transform the XML is minimized.

<%@ Control Language="c#" %>

<%@ Import Namespace="System.XML" %>

<%@ Import Namespace="System.XML.Xsl" %>

<%@ Import Namespace="System.XML.XPath" %>

An example of a page using this user control, Output Caching for 1 minute:

<%@Page%>

<%@ Register TagPrefix="authors" tagname="chapters" src=../../"/controls/chapters.ascx"%>

<%@ OutputCache Duration="60" VaryByParam="none" %>

XMLSource="chapter.XML" xslSource="chapter.xsl" />

To test this out, you can use the following two files:

chapter.XML

Chapter Name

Steven Smith

ssmith@ASPalliance.com

http://ASPalliance.com/stevesmith/

2.1

hellovb.ASP

HelloVB.ASP

hellovb.txt

HelloVB.ASP source

Hello World using Classic ASP.

chapter.xsl


by



Reference Demo Source Description

责任编辑:admin
相关文章