tags:

views:

430

answers:

1
 StringReader rdr = new StringReader(finalXML);

 //Reader is a property which returns XmlTextReader
 Reader = new XmlTextReader(rdr); 
 XmlReader reader = XmlReader.Create(rdr, settings);

The last line throws an exception as the root element is missing because it is at the end of the stream.
_pos value shows that it has read all the characters when I previously assigned it to the property in line 2.
Does any one know how to reset a StringReader?

+1  A: 

Essentially, you don't. Just create a new one... "reader"s are commonly one-way only. In some ways, having a settable "Reader" property that consumes the reader is confusing. Perhaps have a Read(...) or Load(...) method instead? It would be obvious that it has side effects then...

Marc Gravell
Thanks that really helped me!
chugh97