来自流的 XML XSL 转换 [英] XML XSL Transform From Stream

查看:28
本文介绍了来自流的 XML XSL 转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个内存流,我在其中使用 XMLTextWriter 写出一些 XML.我想要做的是使用 XSL.transform 特性转换这个 XML.问题是我不想创建临时文件.XML 文件,我想以某种方式使用流将其转换为 XSL.感谢您的任何建议.

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.

推荐答案

只需使用 XmlReader 并将其传递给 Transform 方法即可.您需要先寻找流的开头.

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.

这篇关于来自流的 XML XSL 转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆