Hi I have a memory stream in which I use XMLTextWriter to write out some XML. What I want to do is transform this XML using the XSL.transform feature. The thing is I don't want to create a temp. XML file, I want to somehow use the stream to Transform it into the XSL. Thank you for any suggestions.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Just use an XmlReader and pass it to the Transform method. You'll need to seek to the start of the stream first.
stream.Seek(0, SeekOrigin.Begin);
XmlReader reader = XmlReader.Create(stream, settings);
XslCompiledTransform transform = new XslCompiledTransform();
transform.Load(...load your transform...);
transform.Transform(reader, resultsWriter);
I've obviously removed certain elements here to simplify the code, but you should get the idea.