我收到此错误:
' ',十六进制值0x19,是无效字符
将DataTable
序列化为XML,然后将此XML反序列化为DataTable
。
这已经有好几个月了,有什么想法,这个角色现在突然发现进入有问题的XML吗?
在VB.NET中工作。这是完成工作的代码。
Public Function ConvertDataTableToXML(ByVal tbl As DataTable) As String
tbl.TableName = "gv"
Dim writer As New System.IO.StringWriter()
tbl.WriteXml(writer, XmlWriteMode.WriteSchema, False)
Return writer.ToString()
End Function
Public Function ConvertXMLToDataTable(ByVal xml As String) As DataTable
Dim tbl As New DataTable
Dim xmlReader As XmlReader = xmlReader.Create(New StringReader(xml))
tbl.ReadXml(xmlReader)
Return tbl
End Function 'This function throws the error.
我还尝试使用正则表达式删除无效字符,但是当表尝试读取XML时我仍然收到错误
答案 0 :(得分:0)
根据W3C XML Recommendation,这些characters are legal in XML:
Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
0x19是unicode END OF MEDIUM,不在允许的设置中。