Tony The Lion
Tony The Lion

Reputation: 63230

XSLTransform to MemoryStream

Can one write the results of a XSLTransform.Transform to a memorystream instead of a XMLTextWriter object?

I need to be able to send the results of my transform over the wire to a webbrowser, so writing it to a file on disk on the server is no good.

Tony

Upvotes: 1

Views: 754

Answers (2)

AJ.
AJ.

Reputation: 16719

The other option is to use the newer XslCompiledTransform, which has an overload to output to a Stream.

Upvotes: 1

GraemeF
GraemeF

Reputation: 11457

You can easily hook an XmlTextWriter up to a StringWriter, and then send the resulting string to the browser:

StringWriter stringWriter = new StringWriter();
XmlTextWriter xmlTextWriter = new XmlTextWriter(stringWriter);

// write your transform to xmlTextWriter...

xmlTextWriter.Flush();
xmlTextWriter.Close();
stringWriter.Flush();

string result = stringWriter.ToString();

Upvotes: 0

Related Questions