FileName具有以下JSON数据:
{“数据”:“ br /> TCT:UTMB在加尔维斯顿(409)772-1011会议室W / BARBARA在PT信息PT室#8FL B翼835 \ u000b <”}
public static void Main(string[] args)
{
try
{
StreamReader reader = new StreamReader(filename);
string response = CodeOf1132(reader.ReadToEnd());
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.LoadXml(response);
}
catch (Exception ex) {}
}
static string CodeOf1132(string message)
{
Response res = DeserializeFromString<Response>(message);
string trimedMessage = res.data.Trim();
return trimedMessage;
}
public static T DeserializeFromString<T>(string serilizedString)
{
T deserializeObject = default(T);
if (!string.IsNullOrEmpty(serilizedString))
{
try
{
deserializeObject = JsonConvert.DeserializeObject<T>(serilizedString);
}
catch (Exception ex){}
}
return deserializeObject;
}
反序列化字符串的输出以下:
br /> TCT:UTMB在加尔维斯顿(409)772-1011 SPOKE W / BARBARA IN PT信息PT会议室#8FL B翼835 << / p>
当以上反序列化的字符串作为xmlDocument.LoadXml()中的输入给出时,它给出了以下异常。
''(十六进制值0x0B)是无效字符。第1行,位置153。