开发者

How to get a Stream from an XMLWriter?

An instance of System.Xml.XmlWriter is writing to an underlying Stream right ?(regardless of what the specific implementation of the XmlWriter is)

So how come there are no methods available for a programmer to retrieve the Strea开发者_JS百科m object from the XmlWriter?

I'm sure I am missing something simple. Thanks in advance.

PS: In case anyone asks, what I really want to do is get the stream from an XmlWriter instance passed to me, and create an XmlReader from it (flush the Writer first if needs be).

I then need to use the XmlReader as a parameter to XslCompiledTransform.Transform method

Edit: punctuation


You should not do it. Even though you know that XmlWriter has some Stream underneath but this is implementation detail and XmlWriter should not give it to you. Also stream may readonly or writeonly, how will you read from it?

You should pass original stream that was used to instantiate XmlWriter to the place where you want to read the stream if you know that stream can be both written and read. Otherwise you should create a new stream which will read the content written by XmlWriter.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜