473,396 Members | 1,847 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 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 2617

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: kinryuu | last post by:
I am setting up an XmlReader in .NET 2.0 beta2. I'm trying to migrate away from the now deprecated XmlValidatingReader. The XML files I'm reading have an in-line schema. I'm noticing several...
6
by: Rob Meade | last post by:
Hi all, I'm having a few difficulties with the above, ie I cant find any good examples anywhere of how to do what I want to do! I have an xml file on my desktop which I want to read in. ...
2
by: jonfroehlich | last post by:
According to the MSDN documentation within the XmlTextReader class for ..NET 2.0, the recommended practice to create XmlReader instances is using the XmlReaderSettings class and the...
1
by: Franck | last post by:
Hi, I'm quit confused with the following problem: I'm tryin to read an Embedded Xml file from my Class Library using a static method which should returns a XmlReader. The point is that using...
2
by: Joe Rattz | last post by:
I am trying to create an XmlReader using XmlReader.Create, but it always returns {None}. I have tried several examples from the web, and Create always returns "{None}". Here is my code: ...
6
by: Mitch | last post by:
Hello, I have a singleton class that loads a config file (for an assembly) into an internal stream object. I designed this class as singleton because it parses the config file many times and I...
7
by: Katit | last post by:
I have string with XML, need to read it using XmlReader. I don't see any way to feed string variable in there. How it's done? Thanks!
1
by: dignan.tenenbaum | last post by:
Hello, I'm using the XmlReader.ReadOuterXml() method to return the string representation of an xml node. The XmlReader is created with a file path and a XmlReaderSettings object. This was...
0
by: gpet44 | last post by:
Hi, I have a problem receiving XML over a NetworkStream in C# .Net 2.0/3.0. I'm creating an XMLReader from the stream. I get the following exception when the XmlReaderreads from the stream as...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.