请教个问题,生成xml文件,中根元素名称为newDataSet,如何修改或删除根元素
本帖最后由 xyk21 于 2012-08-28 15:46:13 编辑 请教个问题,下面的代码可以生成xml文件,但生成的文件中根元素名称为newDataSet,如何修改或删除根元素
Imports System.Data.SqlClient
Public Class frmMain
Dim Conn As SqlConnection
Dim Comm As SqlCommand
Private Sub btnRUN_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRUN.Click
Try
Conn = New SqlConnection("data source=(local);initial catalog=test123;integrated security=false;user id=sa;password=123")
Conn.Open()
Comm = New SqlCommand("sbp_br_outxml", Conn)
Comm.CommandType = CommandType.StoredProcedure
If cbbSJLX.Text = "销售" Then
Comm.Parameters.Add("@leibie", SqlDbType.VarChar, 2).Value = "XS"
ElseIf cbbSJLX.Text = "进货" Then
Comm.Parameters.Add("@leibie", SqlDbType.VarChar, 2).Value = "JH"
End If
Comm.Parameters.Add("@rq1", SqlDbType.VarChar, 20).Value = dtpSTART.Text
Comm.Parameters.Add("@rq2", SqlDbType.VarChar, 20).Value = dtpEND.Text
Dim ds As New DataSet()
Dim ad As New SqlDataAdapter(Comm)
Try
ad.Fill(ds, "test")
dgvDATA.DataSource = ds.Tables("test")
Catch ex As Exception
End Try
Comm.ExecuteNonQuery()
Dim wr As Xml.XmlTextWriter
wr = New Xml.XmlTextWriter("xyk.xml", System.Text.Encoding.GetEncoding("gb2312"))
wr.Formatting = Xml.Formatting.Indented
wr.Indentation = 4
wr.IndentChar = ""
wr.WriteStartDocument()
ds.WriteXml(wr, XmlWriteMode.IgnoreSchema)
wr.Flush()
wr.Close()
Conn.Close()
Catch ex As Exception
End Try
End Sub
End Class