473,729 Members | 2,376 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XmlReader from another using XmlParserContex t and XmlReaderSettin gs

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 XmlReaderSettin gs and a new
XmlParserContex t.

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

XmlReaderSettin gs customSettings = new
XmlReaderSettin gs(...);

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

I have to use an overload of XmlReader.Creat e() that takes both an
XmlReaderSettin gs and an XmlParserContex t 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.Creat e() has _three_ overloads that take
both XmlParserContex t and XmlReaderSettin gs as arguments. But none of
these overloads takes an existing XmlReader. Here are the overloads:

1. XmlReader.Creat e (TextReader, XmlReaderSettin gs, XmlParserContex t)
2. XmlReader.Creat e (Stream, XmlReaderSettin gs, XmlParserContex t)
3. XmlReader.Creat e (String, XmlReaderSettin gs, XmlParserContex t) //
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 2635

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

Similar topics

0
1271
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 alarming problems: 1) The documentation for XmlReader says to use and XmlReaderSettings object and to either add or remove IgnoreInlineSchema from the ValidationFlags property as desired. Well, the ValidationFlags property uses the...
6
2402
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. Having checked the info for XML file reading it suggests that with .net 2.0 you should use the XMLReader class...
2
6856
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 XmlReader.Create() method. However, the problem is, the XmlReader class does not expose certain properties that I need, e.g., LineNumber, LinePosition, etc. I would like to follow Microsoft's recommended practices, but I'm not sure how I can get XmlTextReader...
1
3498
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 DataSet or XmlDocument works perfectly... using XmlReader always fails. I always get "None" as a result. Even using XmlReaderSettings does not change anything.
2
7631
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: XmlReaderSettings settings = new XmlReaderSettings(); settings.ConformanceLevel = ConformanceLevel.Fragment; settings.IgnoreWhitespace = true; settings.IgnoreComments = true;
6
2142
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 do not want to load the config file everytime. The problem is I am using XMLReader because of speed and after I read an item (multiple nodes so pass node name and element name) and try to read another item I get an error "root element missing". ...
7
44538
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
4386
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 working fine until a default namespace was introduced. When the default namespace is defined the ReadOuterXml() method began adding a bunch of extra namespace declarations to the string it returned. xml example ...
0
2450
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 follows while(reader.Read()) { ... } System.Xml.XmlException: Unexpected XML declaration. The XML declaration must be the first node in the document, and no white space characters are allowed to appear before it. Line 2, position 3. Unfortunately I...
0
8917
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9426
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8148
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6722
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6022
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4795
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3238
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2163
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.