[英]XSLTransform to MemoryStream
Can one write the results of a XSLTransform.Transform to a memorystream instead of a XMLTextWriter object? 可以将XSLTransform.Transform的结果写到内存流而不是XMLTextWriter对象中吗?
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. 我需要能够将电线的转换结果发送到Web浏览器,因此将其写入服务器上磁盘上的文件是不好的。
Tony 托尼
另一个选择是使用较新的XslCompiledTransform ,它具有重载以输出到Stream。
You can easily hook an XmlTextWriter up to a StringWriter, and then send the resulting string to the browser: 您可以轻松地将XmlTextWriter挂钩到StringWriter,然后将结果字符串发送到浏览器:
StringWriter stringWriter = new StringWriter();
XmlTextWriter xmlTextWriter = new XmlTextWriter(stringWriter);
// write your transform to xmlTextWriter...
xmlTextWriter.Flush();
xmlTextWriter.Close();
stringWriter.Flush();
string result = stringWriter.ToString();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.