private byte[] DocToBytes(XmlDocument doc) { MemoryStream ms = new MemoryStream (); XmlTextWriter xw = new XmlTextWriter (ms, null); xw.Formatting = Formatting.Indented; doc.WriteTo (xw); xw.Flush (); return ms.ToArray (); }