All,
I have the code below for converting an XML document using XSLT. The problem is that in an XML document, about 12 MB in C # runs out of memory. Is there any other way to do the conversion without consuming so much memory?
public string Transform(XPathDocument myXPathDoc, XslCompiledTransform myXslTrans)
{
try
{
var stm = new MemoryStream();
myXslTrans.Transform(myXPathDoc, null, stm);
var sr = new StreamReader(stm);
return sr.ReadToEnd();
}
catch (Exception e)
{
}
}
Here is the stack trace:
at System.String.GetStringForStringBuilder(String value, Int32 startIndex, Int32 length, Int32 capacity)
at System.Text.StringBuilder.GetNewString(String currentString, Int32 requiredLength)
at System.Text.StringBuilder.Append(Char[] value, Int32 startIndex, Int32 charCount)
at System.IO.StreamReader.ReadToEnd()
at Transform(XPathDocument myXPathDoc, XslCompiledTransform myXslTrans)
source
share