You just modify the CAB library, which can extract the template file into memory, like this one,
Minimal C # code to extract from .CAB archives or InfoPath XSN files in memory
And then call myCab.ExtractFile("template.xml", out buffer, out bufferLen);
full code would look like
private byte[] GetXmlForm(SPDocumentLibrary list) {
byte[] data = null;
SPFile file = list.ParentWeb.GetFile(list.DocumentTemplateUrl);
Stream fs = file.OpenBinaryStream();
try {
data = new byte[fs.Length];
fs.Read(data, 0, data.Length);
} finally {
fs.Close();
}
byte[] buffer;
int bufferLen;
CabExtract cab = new CabExtract(data);
cab.ExtractFile("template.xml", out buffer, out bufferLen);
return buffer;
}
source
share