Writing and Reading XML Documents

The easiest and quickest means of writing and reading XML documents is via the XmlTextWriter and XmlTextReader classes. I'll first explain how to create and write XML documents and then how to read those documents—parsing for the desired node types and values. Once that is done, you'll see a demo illustrating how to use these classes in writing and reading a simple XML file containing book-detail information.

Writing XML Documents

The first thing to understand about the XmlTextWriter class is that it encapsulates a fast, noncached, forward-only way of generating streams or files containing XML data that conforms to the W3C standards for XML. Therefore, it can only be used to write from beginning to end an XML ...

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.