Creating a DOM Implementation
In order to parse XML documents with DOM, we first need a method to generate a DOM implementation. With .NET the DOM implementation is called XmlDocument, which represents an entire parsed DOM document. The DOM implementation, however, is not its own parser. In fact, much like the XMLValidatingReader, it relies on a lower-level parser like the XmlTextReader to actually generate the parsed data for it. That's exactly what will be done in this example. First, an XmlTextReader is created for the example document.
XmlTextReader xmlReader = new XmlTextReader("example.xml");
Note
Although XmlDocument does provide an implementation of the Document Object Model, many of the methods and properties have been changed to better ...
Get Special Edition Using XML, Second Edition 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.