我将数组传递给一个将数组转换为XML的函数。但我无法使用"<"
或"&"
等特殊字符。当我传递这些时,它会给出错误无效的XML文件。
Protected Sub drawgraph(ByRef dt As DataTable, ByVal name As String)
Try
Dim n(dt.Columns.Count - 3) As String
Dim r(dt.Columns.Count - 3) As String
For i As Integer = 1 To dt.Columns.Count - 2
***n(i - 1) = dt.Columns(i).ColumnName.ToString.Replace("<", "<")***
r(i - 1) = (dt.Rows(0).Item(i))
Next
ChartBuilder1.BuildLabel(n)
ChartBuilder1.BuildValues(r, "Age Profile")
ChartBuilder1.GenerateGraph()
ChartBuilder1.Visible = True
Catch ex As Exception
lbl_msg.Text = ex.Message
End Try
End Sub
我正在用"<"
替换"<"
,但它无效
答案 0 :(得分:7)
使用HttpServerUtility.HtmlEncode“转义”特殊字符。
“&LT;”变为<