473,241 Members | 1,491 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,241 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 2608

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: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.