The DOM and the XmlDocument Class

As the XmlDocument class is an encapsulation of the DOM (Document Object Model), let's first get a basic overview of what the DOM is and how the capabilities it provides compare with what you've learned up to this point.

The DOM is an in-memory representation of an XML document that allows you to read, edit, and save XML data. However, unlike the XmlTextWriter/XmlTextReader class pair, the DOM doesn't view the XML data in a linear fashion. Instead, when the DOM loads an XML document, the document is parsed, and the data is represented as a tree of related nodes. As an example, take a look the following, more expanded, version of our earlier BookDetail XML document:

 <?xml version="1.0"?> <BookDetail> <Book ISBN="032117352X"> ...

Get Extending MFC Applications with the .NET Framework now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.