Infopath XML read and write
1.SHLF
Stream source = properties.ListItem.File.OpenBinaryStream();
byte[] buffer = new byte[source.Length];
source.Read(buffer, 0, (Int32)source.Length);
String filecontent=Encoding.UTF8.GetString(buffer);
filecontent = filecontent.Replace("LFSH00001", GetLatestID());
byte[] dest = Encoding.UTF8.GetBytes(filecontent);
properties.ListItem.File.SaveBinary(dest);