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. 0 2638 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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...
|
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...
|
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...
|
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.
|
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;
| |
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". ...
|
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!
|
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 ...
|
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...
|
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...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |