Same memory stream and same XmlReader: reading more times.

  • Thread starter Thread starter BLUE
  • Start date Start date
B

BLUE

I can set memory stream position to 0 to "reset" it to the initial position,
but is there a similar method to reset XmlReader position (else it is at
EOF)?
I've seen deprecated XmlTextReader had ResetState method... why XmlReader
has not?


Thanks,
Luigi.
 
BLUE said:
I can set memory stream position to 0 to "reset" it to the initial
position, but is there a similar method to reset XmlReader position (else
it is at EOF)?
I've seen deprecated XmlTextReader had ResetState method... why XmlReader
has not?

Both methods are read forward only methods. You can't read previous and you
can't move to a position. You can only read forward.

<ResetState>

This method enables you to parse multiple XML documents in a single stream.
When you reach the end of an XML document, you can call ResetState to reset
the state of the reader in preparation for the next XML document.

<ResetState>
 
Luigi,

The only way that you can do this is if you get the underlying stream
that the reader is attached to and then set the position of the stream to
the beginning. If you do this, you will probably have to create a new
reader and pass the stream to that, as you can't tell if the old one is
caching information read from the underlying stream or not.
 
Back
Top