ถ้ามันเป็น DataSet หรือ DataTable สามารถ Export เป็น XML ได้เลยครับ
Code (VB.NET)
Dim objConn As New OleDbConnection
Dim objCmd As New OleDbCommand
Dim dtAdapter As New OleDbDataAdapter
Dim ds As New DataSet
Dim strConnString,strSQL As String
strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("database/mydatabase.mdb")&";"
strSQL = "SELECT * FROM customer"
objConn.ConnectionString = strConnString
With objCmd
.Connection = objConn
.CommandText = strSQL
.CommandType = CommandType.Text
End With
dtAdapter.SelectCommand = objCmd
dtAdapter.Fill(ds)
dtAdapter = Nothing
objConn.Close()
objConn = Nothing
'*** Export XML ***'
ds.Tables(0).WriteXML(Server.MapPath("XML/myXml.xml"))
'ds.Tables(0).WriteXmlSchema(Server.MapPath("XML/myXml.xml"))
ds = Nothing