我有一些DataTables
想要导出到xml
文件中。我可以DataTable.WriteXml()
用来输出 to 的DataTables
内容XML
。
我需要使用Response object
如图所示的。我需要将属性添加到输出 xml 的根目录。请帮帮我。这是我正在处理的代码。
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim FileName1 As String = "Sheet1.xml"
Response.Clear()
Response.AddHeader("Content-Disposition", "attachment; filename=" & FileName1)
Response.ContentType = "text/xml"
Dim ds As New DataSet("BuildingGroups")
ds.EnforceConstraints = False
Dim dtBuildingGroup As DataTable = Pipeline.Products.Components.BuildingGroupManager.GetBuildingGroupsToXML
Dim result As String
Dim sw As New StringWriter()
dtBuildingGroup.TableName = "BuildingGroup"
ds.Tables.Add(dtBuildingGroup)
'Dim doc As New XmlDataDocument(ds)
ds.WriteXml(sw)
result = sw.ToString()
Response.Write(result)
Response.End()
End Sub