<%@ Page Language="VB"
AutoEventWireup="false"
CodeFile="Default.aspx.vb"
Inherits="_Default" %>
File: Data.xslt
Imports System.Data
Imports System.Data.SqlClient
Imports System.IO
Imports System.Xml
Imports System.Xml.XPath
Imports System.Xml.Xsl
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles Me.Load
Dim connStr As String = "database=Northwind;Data Source=.\SQLEXPRESS;" & _
" User id=Tom;pwd=password"
Dim x As New XmlDocument()
Dim xpathnav As XPathNavigator = x.CreateNavigator()
Using conn As New SqlConnection(connStr)
conn.Open()
Dim command As New SqlCommand("select * from Customers as Customer " & _
"for XML AUTO, ELEMENTS", conn)
Using xw As XmlWriter = xpathnav.PrependChild()
xw.WriteStartElement("Customers")
Using xr As XmlReader = command.ExecuteXmlReader()
xw.WriteNode(xr, True)
End Using
xw.WriteEndElement()
End Using
End Using
Xml1.XPathNavigator = xpathnav
End Sub
End Class
File: Data.xslt
List of Customers
Company Name Contact Name Contact Title