我们有一个 xml 提要,我需要删除换行符并从字段中修剪结束的空格。我通过以下方式生成 XML:
Protected Sub GenerateXML(ByVal type As String)
Dim ds As New DataSet
Dim connStr As String = "database=M**********"
Dim selectCommand As String
If type = "standard" Then
selectCommand = "select * from JobList where username = '" & username & "' and status in ('" & status & "','Cancelled', 'Assessed', 'Remove')"
Else
selectCommand = "select * from JobList where username = '" & username & " '"
End If
Using conn As New SqlConnection(connStr)
Dim command As New SqlCommand(selectCommand, conn)
conn.Open()
ds.DataSetName = "Locations"
ds.Load(command.ExecuteReader(), LoadOption.OverwriteChanges, "Location")
For Each r As DataRow In ds.Tables("Location").Rows
If r("status") = "Assessed" Then
r("status") = "Cancelled"
End If
Next
ds.AcceptChanges()
Response.ContentType = "text/xml"
ds.WriteXml(Response.OutputStream)
End Using
End Sub
有没有办法让我通过进入 ds 的每一行进行替换?还是我必须以另一种方式生成 XML?
塔肯