0

XmlTextWriter allows 0x15 and 0x1A. Does anyone know how to get around this? If I serialize a string of XML containing the mentioned illegal characters XmlTextWriter allows this with no exceptions. Does anyone have a work around for this?

Maess
  • 4,118
  • 20
  • 29
  • FYI, you should not use `new XmlTextReader()` or `new XmlTextWriter()`. They have been deprecated since .NET 2.0. Use `XmlReader.Create()` or `XmlWriter.Create()` instead. – John Saunders Jan 29 '14 at 22:02
  • Out of curiosity: why are these illegal? `0x15` is just `21` decimal, what's special about that? – Jeroen Vannevel Jan 29 '14 at 22:04
  • Before now I've just done a blind replace for any "banned" characters - but obviously that loses data. Unfortunately in XML 1.0 there isn't really a nice workaround for it - the characters are still invalid even when specified as an entity :( – Jon Skeet Jan 29 '14 at 22:04
  • 1
    @JeroenVannevel: Only a few characters in the range U+0000 to U+001F are legal :( See http://www.w3.org/TR/REC-xml/#charsets – Jon Skeet Jan 29 '14 at 22:04
  • @JonSkeet: cheers, that clarifies some things. Character sets.. *shudder* – Jeroen Vannevel Jan 29 '14 at 22:10
  • Thanks for the helpful comments, we ending up solving the issue using XmlConvert.IsXmlChar – Maess Jan 30 '14 at 13:20

0 Answers0