Can you get a Char 0x05 into an XDocument that will then throw on XDocument.ToString?
-
13-06-2021 - |
سؤال
I have an XDocument
that is throwing an invalid character (0x05) exception on ToString
.
To help locate where I could be allowing a 0x05 char in where in the XDocument API can you let in a 0x05 character without some exception at that point, only to be thrown at ToString
?
Specifically, as far as I recall, I only use the new Linq XML API, except that I do use some XmlSerialization through an extension method to return it to an XElement
.
Just to show this was a worthy question before I found the simple answer: XElement:Parse
does throw when the 0x05 character is included.
المحلول
I've found that simply setting the .Value
of an XElement
does not check for invalid charaters :-(
element.Value = "test" & Chr(5) & "5"
The above doesn't throw, until you then call XDocument.ToString
on the containing Xml.