TopBanana9000
TopBanana9000

Reputation: 898

' ', hexadecimal value 0x19, is an invalid character?

I am receiving this error:

' ', hexadecimal value 0x19, is an invalid character

when serializing a DataTable as XML, then deserializing this XML back to a DataTable.

This is something that has been working for months now, any ideas how this character is now all of a sudden finding its way into the XML in question?

Working in VB.NET. Here is the code that does the work.

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.

I've tried to strip invalid characters out using regex expressions also but I am still receiving the error when the table tries to read the XML

Upvotes: 0

Views: 2895

Answers (1)

kjhughes
kjhughes

Reputation: 111756

Per the W3C XML Recommendation, these characters are legal in XML:

Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]

0x19 is unicode END OF MEDIUM and is not in the allowed set.

Upvotes: 0

Related Questions