本文整理匯總了VB.NET中System.Xml.Xsl.XslTransform.Transform方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET XslTransform.Transform方法的具體用法?VB.NET XslTransform.Transform怎麽用?VB.NET XslTransform.Transform使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Xml.Xsl.XslTransform
的用法示例。
在下文中一共展示了XslTransform.Transform方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: Sample
' 導入命名空間
Imports System.IO
Imports System.Data
Imports System.Data.SqlClient
Imports System.Xml
Imports System.Xml.XPath
Imports System.Xml.Xsl
public class Sample
public shared sub Main()
' Create a DataSet and load it with customer data.
Dim dsNorthwind as DataSet = new DataSet()
Dim sConnect as String
sConnect="Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind"
Dim nwconnect as SqlConnection
nwconnect = new SqlConnection(sConnect)
Dim sCommand as String = "Select * from Customers where Region='WA'"
Dim myDataAdapter as SqlDataAdapter
myDataAdapter = new SqlDataAdapter(sCommand, nwconnect)
myDataAdapter.Fill(dsNorthwind,"Customers")
' Load the DataSet into an XmlDataDocument.
Dim doc as XmlDataDocument = new XmlDataDocument(dsNorthwind)
' Create the XslTransform object and load the stylesheet.
Dim xsl as XslTransform = new XslTransform()
xsl.Load("customers.xsl")
' Create an XPathNavigator to use in the transform.
Dim nav as XPathNavigator = doc.CreateNavigator()
' Create a FileStream object.
Dim fs as FileStream = new FileStream("cust.html", FileMode.Create)
' Transform the data.
xsl.Transform(nav, nothing, fs, nothing)
end sub
end class
示例2: Sample
Option Strict
Option Explicit
Imports System.IO
Imports System.Xml
Imports System.Xml.Xsl
Imports System.Xml.XPath
Public Class Sample
Private Shared filename1 As String = "books.xml"
Private Shared stylesheet1 As String = "output.xsl"
Public Shared Sub Main()
'Load the stylesheet.
Dim xslt As New XslTransform()
xslt.Load(stylesheet1)
'Load the file to transform.
Dim doc As New XPathDocument(filename1)
'Create an XmlTextWriter which outputs to the console.
Dim writer As New XmlTextWriter(Console.Out)
'Transform the file and send the output to the console.
xslt.Transform(doc, Nothing, writer, Nothing)
writer.Close()
End Sub
End Class
示例3: Main
' 導入命名空間
Imports System.IO
Imports System.Xml
Imports System.Xml.Xsl
Imports System.Xml.XPath
public class Sample
public shared sub Main()
' Create a string containing the XSLT stylesheet.
Dim xsltString as String
xsltString = "<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>" & _
" <xsl:template match='bookstore'>" & _
" <HTML>" & _
" <HEAD>" & _
" <TITLE>Book Titles</TITLE>" & _
" </HEAD>" & _
" <BODY>" & _
" <xsl:apply-templates select='book'/>" & _
" </BODY>" & _
" </HTML>" & _
" </xsl:template>" & _
" <xsl:template match='book'>" & _
" <P><xsl:value-of select='title'/></P>" & _
" </xsl:template>" & _
" </xsl:stylesheet>"
' Create the XslTransform object.
Dim xslt as XslTransform = new XslTransform()
' Load the stylesheet.
Dim rdr as StringReader = new StringReader(xsltString)
xslt.Load(new XPathDocument(rdr), nothing, nothing)
' Transform the file and output an HTML string.
Dim HTMLoutput as string
Dim writer as StringWriter = new StringWriter()
xslt.Transform(new XPathDocument("books.xml"), nothing, writer, nothing)
HTMLoutput = writer.ToString()
end sub
end class
示例4: XmlUrlResolver
' Create a resolver with default credentials.
Dim resolver as XmlUrlResolver = new XmlUrlResolver()
resolver.Credentials = System.Net.CredentialCache.DefaultCredentials
' Create the XslTransform object.
Dim xslt as XslTransform = new XslTransform()
' Load the stylesheet.
xslt.Load("http://myServer/data/authors.xsl", resolver)
' Transform the file.
xslt.Transform("books.xml", "titles.xml", resolver)
示例5: XslTransform
' Create the XslTransform object.
Dim xslt as XslTransform = new XslTransform()
' Load the stylesheet.
xslt.Load("titles.xsl")
' Create a resolver and specify the necessary credentials.
Dim resolver as XmlUrlResolver = new XmlUrlResolver()
Dim myCred as System.Net.NetworkCredential
myCred = new System.Net.NetworkCredential(UserName,SecurelyStoredPassword,Domain)
resolver.Credentials = myCred
' Transform thefile using the resolver. The resolver is used
' to process the XSLT document() function.
Dim doc as XPathDocument = new XPathDocument("books.xml")
Dim reader as XmlReader = xslt.Transform(doc, nothing, resolver)
' Load the reader into a new document for more processing.
Dim xmldoc as XmlDocument = new XmlDocument()
xmldoc.Load(reader)
示例6: XmlDocument
Dim doc as XmlDocument = new XmlDocument()
doc.Load("books.xml")
' Modify the XML file.
Dim root as XmlElement = doc.DocumentElement
root.FirstChild.LastChild.InnerText = "12.95"
' Create an XPathNavigator to use for the transform.
Dim nav as XPathNavigator = root.CreateNavigator()
' Transform the file.
Dim xslt as XslTransform = new XslTransform()
xslt.Load("output.xsl")
Dim writer as XmlTextWriter = new XmlTextWriter("books.html", nothing)
xslt.Transform(nav,nothing, writer, nothing)
示例7: XslTransform
'Create the XslTransform object.
Dim xslt as XslTransform = new XslTransform()
'Load the stylesheet.
xslt.Load("output.xsl")
'Transform the file.
xslt.Transform("books.xml", "books.html")
示例8: SymEnc
' 導入命名空間
Imports System.Xml.Xsl
Public Class SymEnc
Public Shared Sub Main(ByVal CmdArgs() As String)
Dim myXslTransform As XslTransform = New XslTransform()
Dim destFileName As String = "ShowIt.html"
myXslTransform.Load("xsltFile.xslt")
myXslTransform.Transform("xmlFile.xml", destFileName)
System.Diagnostics.Process.Start(destFileName)
End Sub
End Class