471,624 Members | 1,902 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,624 software developers and data experts.

XmlReader from another using XmlParserContext and XmlReaderSettings

Jen
My main question: "How can I get a TextReader or Stream object from an
existing XmlReader?". Read on for more:

I have an existing XmlReader. Let's call it reader1. I'm creating
another reader, reader2, after creating new XmlReaderSettings and a new
XmlParserContext.

// customContext and customSettings may or may not make use
reader1's properties
XmlParserContext customContext = new XmlParserContext(...);

XmlReaderSettings customSettings = new
XmlReaderSettings(...);

// This won't work, because reader1 isn't a TextReader,
Stream or URI.
XmlReader reader2 = XmlReader.Create(reader1,
customSettings, customContext);

I have to use an overload of XmlReader.Create() that takes both an
XmlReaderSettings and an XmlParserContext as arguments, because they
cannot be set AFTER the XmlReader has been created. (Actually, Settings
can be set post-creation, but not the context, and customContext is
important.)

Here's the problem. XmlReader.Create() has _three_ overloads that take
both XmlParserContext and XmlReaderSettings as arguments. But none of
these overloads takes an existing XmlReader. Here are the overloads:

1. XmlReader.Create (TextReader, XmlReaderSettings, XmlParserContext)
2. XmlReader.Create (Stream, XmlReaderSettings, XmlParserContext)
3. XmlReader.Create (String, XmlReaderSettings, XmlParserContext) //
String is the URI

I believe that both (1) and (2) should work no matter what XmlReader
reader1 is. What's the easiest way to get a TextReader or Stream object
from an existing XmlReader? I don't think that there are easier ways to
do what I'm trying to do.

Jan 16 '06 #1
0 2513

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Rob Meade | last post: by
2 posts views Thread by jonfroehlich | last post: by
1 post views Thread by Franck | last post: by
2 posts views Thread by Joe Rattz | last post: by
6 posts views Thread by Mitch | last post: by
7 posts views Thread by Katit | last post: by
reply views Thread by leo001 | last post: by
1 post views Thread by ZEDKYRIE | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.