Thanks - that seems like a good way to do it but the line number position and offset values always seem to be 0??? Even after numerous .Read() operations??
Main Topics
Browse All TopicsHi
I have two XML reader objects, readerA and readerB which read the same XML.
I then perform a number of read operations on readerA, which moves readerA to a different position to readerB.
Now, I want to set readerB's position to the same position as that of readerA.
But if I do the following:
readerA = readerB;
I seem to do a shallow copy of readerA and everytime I do a read on readerA thereafter, readerB reads as well.
How do I do a proper copy of readerB from readerA, without having readerB read everytime readerA does??
Thanks
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
For this to work the undelining stream need to have lines (i.e. a file):
http://msdn.microsof
Can you provide more information about the use case, and maybe we can find a different solution for this problem?
Sure - what I am doing is creating two xmlReaders, readerA and readerB.
Due to the fact that these xmlReaders can't move backwards, I use readerB to read forward and search for a particular element. If I find this element, I want to reset readerB's position to that of readerA's.
So my thought was to recreate readerB with xmlReaderSettings lineNumber set to that of readerA.
I do not want to use xmlDocument due to the performance implications either.
You see where I'm coming from?
Thanks
You could use XmlTextReader.GetRemainder
The problem is that these are XmlReaders, not XMLTextReaders.
I could change them to XmlTextReader, but then I lose the ability to set the "ConformanceLevel = Fragment" setting of the XmlReader, which is critical .
What I also can't understand why you can't assign XMLReaderSettings to an XmlTextReader when XmlTextReader inherits from XmlReader??
Ok - I found a way how to accomplish what I was looking for. It builds on your idea of creating a new XmlTextReader from the position of another.
What I did was create XmlTextReader C, and while C's.Position is less than the original XmlTextReaders position, then I just keep reading within TextReader C. Eventually it lands up at the same position as the original :)
Thanks for the help
Business Accounts
Answer for Membership
by: moseackPosted on 2008-11-03 at 02:22:19ID: 22865800
Simplest approach is to use XmlReader.Create with the appropriate XmlReaderSettings (line number and position offsets).