Reading and Writing XML Documents

Two primary classes in this group are XmlReader and XmlWriter. Both of these classes are abstract classes, and therefore we cannot create objects of these classes. Microsoft has provided a number of concrete implementations of both of these classes:

■ XmlTextReader We may use an object of this class to read non-cached XML data on a forward-only basis. It checks for well-formed XML, but it does not support data validation.

■ XmlNodeReader An object of this class can be used to access non-cached forward-only data from an XML node. It does not support data validation.

■ XmlValidationReader This is very similar to the XMLTextReader, except that it accommodates XML data validation.

We may create objects of these classes and use their methods and properties. If warranted, we may also extend these classes to provide further specific functionalities. Fortunately, the XmlWriter class has only one concrete implementation: XmlTextWriter. It can be used to write XML document on a forward-only basis. These classes and their relationships are shown in Figure 8.9.

Figure 8.9 Major XmlReader and XmlWriter Classes

0 0

Post a comment