⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xsl-transform.aspx

📁 This is a book about vb.you could learn this from this book
💻 ASPX
字号:
<%@Page Language="VB"%>
<%@Import Namespace="System.Xml" %>
<%@Import Namespace="System.Xml.Xsl" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head>
<title>Transforming an XML document using the XSLTransform object</title>
<!-- #include file="..\global\style.inc" -->
</head>
<body bgcolor="#ffffff">
<span class="heading">Transforming an XML document using the XSLTransform object</span><hr />
<!--------------------------------------------------------------------------->

Using XML document file:
<b><span id="outXMLURL" runat="server"></span></b><br />
Loaded XSL stylesheet file:
<b><span id="outXSLURL" runat="server"></span></b><br />
Written new HTML disk file:
<b><span id="outHTMLURL" runat="server"></span></b><br />
<div id="outError" runat="server">&nbsp;</div>
<div id="outResults" runat="server"></div>

<script language="vb" runat="server">

Sub Page_Load()

   'create physical path to booklist sample files (in same folder as ASPX page)
   Dim strCurrentPath As String = Request.PhysicalPath
   Dim strXMLPath As String = Left(strCurrentPath, InStrRev(strCurrentPath, "\")) & "booklist.xml"
   Dim strXSLPath As String = Left(strCurrentPath, InStrRev(strCurrentPath, "\")) & "booklist.xsl"
   Dim strHTMLPath As String = Left(strCurrentPath, InStrRev(strCurrentPath, "\")) & "booklist.html"
   outXMLURL.InnerHtml = "<a href=""" & strXMLPath & """>" & strXMLPath & "</a>"

   Try

      'create a new XslTransform object
      Dim objTransform As New XslTransform()

      'load the XSL stylesheet into the XSLTransform object
      objTransform.Load(strXSLPath)
      outXSLURL.InnerHtml = "<a href=""" & strXSLPath & """>" & strXSLPath & "</a>"

      'perform the transformation using the XSL file in the
      'XSLTransform and the XML file path in strXMLPath
      'the result is sent to the disk file in strHTMLPath
      objTransform.Transform(strXMLPath, strHTMLPath)
      outHTMLURL.InnerHtml = "<a href=""" & strHTMLPath & """>" & strHTMLPath & "</a>"

   '------------ error handling code -------------
   Catch objError As Exception

      'display error details
      outError.innerHTML = "<b>* Error while accessing document</b>.<br />" _
          & objError.Message & "<br />" & objError.Source
      Exit Sub  ' and stop execution

   End Try

End Sub

</script>

<!--------------------------------------------------------------------------->
<!-- #include file="..\global\foot.inc" -->
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -