I am getting exception
'', hexadecimal value 0x0B, is an invalid character. Line 23, position 22.
I have already tried solution from Here, but it is not working for me. As my project is in 3.5 version, I cannot use XmlConvert.IsXmlChar
method MSDN
How to handle it ?
XmlException hexadecimal value 0x02, is an invalid character.. its, pointing to this line: var result = from x in XDocument.
You can replace these invalid characters using the below method.
public static string CleanInvalidXmlChars(this string StrInput)
{
//Returns same value if the value is empty.
if (string.IsNullOrWhiteSpace(StrInput))
{
return StrInput;
}
// From xml spec valid chars:
// #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
// any Unicode character, excluding the surrogate blocks, FFFE, and FFFF.
string RegularExp = @"[^\x09\x0A\x0D\x20-\xD7FF\xE000-\xFFFD\x10000-x10FFFF]";
return Regex.Replace(StrInput, RegularExp, String.Empty);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With