开发者

XmlTextReader move to start

This is my requirement i need to deserialize an object and then i need to do some xml parsing(i know how it sounds)

So here is my code

XmlTextReader myFileReader = new XmlTextReader(path); 
XmlSerializer serializer = new XmlSerializer(typeof(MyType)); 
MyType par = serializer.Deserialize(myFileReader)  as MyType;

XElement qListenerParXml = XElement.Load(qL开发者_C百科istenerPar);

When i try to load the reader again i'm getting exception because the reader cursor is at the end. My question is how do i return it back to the beginning?


XmlTextReader is forward-only, you cannot rewind the cursor on the data.

You could do this by going over the data again with a new instance of XmlTextReader, or by loading it as an XmlDocument.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜