Introducing the XmlNodeReader Class

The XmlNodeReader class is very similar to the XmlTextReader class—something that isn't so surprising when you consider that they share the same parent class. Like XmlTextReader, the XmlNodeReader class allows for forward-only, noncached traversal of XML; where they differ is in their source. The XmlNodeReader is implemented across the node of an existing XmlDocument instance. Creating a node reader instance will look familiar to you. First, we instance an XmlDocument object and load a file into it. Then we pass the XmlDocument instance into the constructor for the XmlNodeReader object:

 'Create an XmlNodeReader to read the XmlDocument. Dim doc As New XmlDocument() doc.Load(filename) reader = New XmlNodeReader(doc) ...

Get Visual Basic® Programmer's Guide to the .NET Framework Class Library 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.