412 Chapter 8 • Using XML in the .NET Framework
Reading and Parsing Using the XmlTextReader Class
;The XmlTextReader class provides a fast forward-only cursor to pull data from an XML document.
;Some of the frequently used methods and properties of the
XmlTextReader class include AttributeCount, Depth, EOF, HasAttributes, HasValue, IsDefault, IsEmptyElement, Item, ReadState, and Value.
;The Read() of an XmlTextReader object enables you to read data sequentially.The MoveToAttribute() method can be used to iterate through the attribute collection of an element.
Writing an XML Document
Using the XmlTextWriter Class
;An XmlTextWriter class can be used to write data sequentially to an output stream, or to a disk file as an XML document.
;Its major methods and properties include Close, Flush, Formatting, WriteAttribues,WriteAttributeString,WriteComment,WriteElementString, WriteElementString,WriteEndAttribute,WriteEndDocument,WriteState, and WriteStartDocument.
;Its constructor contains a parameter that can be used to specify the output format of the XML document. If this parameter is set to “Nothing,” then the document is written using UTF-8 format.
Exploring the XML Document Object Model
;The W3C Document Object Model (DOM) is a set of the specifications to represent an XML document in the computer’s memory.
;XmlDocument class implements both the W3C specifications (Core level 1 and 2) of DOM.
;XmlDocument object also allows navigating through XML node tree using XPath expressions.
;XmlDataDocument is an extension of XmlDocument class.