Saturday, November 13, 2010

Difference Between XmlTextReader and XmlDocument

XmlDocument represents the contents of an xml file. When loading it from a file, you read the entire file into memory.
XmlReader is an abstract class able to read from xml data. It can read from a file, from an internet location, or from any other stream of data. When reading from a file, you don't load the entire document at once.
XmlTextReader is an implementation of XmlReader able to read xml from a file. It's recommended to use XmlReader.Create(file) instead of instantiating an XmlTextReader.


XmlTextReader is forward only stream, while XmlDocument is both forward and backward.

We use XMLTextReader to read XML streams. XMLdocument can be used to edit and navigate the document.

No comments:

Followers

Link