I am currently running a live 'in-memory' XSLT transformation using the following code
XmlDocument XmlDoc = new XmlDocument(); XmlDoc.LoadXml(DS.GetXml()); XslCompiledTransform XsltTranformation = new XslCompiledTransform(); XsltTranformation.Load(@"C:\Users\maskew\Desktop\XSLTMapping.xsl"); Stream XmlStream = new MemoryStream(); XmlDoc.Save(XmlStream); //Stream is still blank after this line XmlReader XmlRdr = XmlReader.Create(XmlStream); MemoryStream stm = new MemoryStream(); XsltTranformation.Transform(XmlRdr, null, stm); stm.Position = 1; StreamReader sr = new StreamReader(stm); string Output = sr.ReadToEnd(); Output = Output.Substring(2); XmlDoc.LoadXml(Output); XmlWriter XmlWrtr = XmlWriter.Create(@"C:\Users\maskew\Desktop\XmlMapping.xml"); XmlDoc.WriteTo(XmlWrtr); XmlWrtr.Flush(); XmlWrtr.Close();
However, when I move the file from XmlDocument to MemoryStream in line 8 the stream contains nothing when checked and thus stopping the whole program from running.
Does anyone have any idea why this would be occuring?
Edited 4 Years Ago by Mike Askew: Added correct line number