J
JaguarsJag
Guest
I am receiving an xml file with some special characters coming in the data. It is making as invalid xml.
I need to preprocess the xml removing all the special characters. I tried below method but it can replace only '&' with '&'
Is there a way when I receive ( '&', '<', '>') characters, I can replace them with & > <
public static Message Replace(Message inmsg)
{
System.IO.Stream st = inmsg.BodyPart.GetOriginalDataStream();
System.IO.StreamReader reader = new System.IO.StreamReader(st);
string body = reader.ReadToEnd();
body = body.Replace(_FindString, _ReplaceString);
System.IO.MemoryStream m = new System.IO.MemoryStream();
System.IO.StreamWriter writer = new System.IO.StreamWriter(m);
writer.AutoFlush = true;
writer.Write(body);
m.Position = 0;
inmsg.BodyPart.Data = m;
reader.Close();
return inmsg;
}
MBH
Continue reading...
I need to preprocess the xml removing all the special characters. I tried below method but it can replace only '&' with '&'
Is there a way when I receive ( '&', '<', '>') characters, I can replace them with & > <
public static Message Replace(Message inmsg)
{
System.IO.Stream st = inmsg.BodyPart.GetOriginalDataStream();
System.IO.StreamReader reader = new System.IO.StreamReader(st);
string body = reader.ReadToEnd();
body = body.Replace(_FindString, _ReplaceString);
System.IO.MemoryStream m = new System.IO.MemoryStream();
System.IO.StreamWriter writer = new System.IO.StreamWriter(m);
writer.AutoFlush = true;
writer.Write(body);
m.Position = 0;
inmsg.BodyPart.Data = m;
reader.Close();
return inmsg;
}
MBH
Continue reading...