Thursday, June 7, 2007

Dot Net Questions - XML Reader Class

Xml reader and xml writer comes from namespace system.xml. These classes' helps in getting data from xml documents both of these classes are abstract base classes.

The xml reader class helps in to get xml data in stream or xml documents. This class provides fast, non-cacheable, read only access to xml data as the name suggest it is only forward only access. As I have told that this class is a abstract class and provide methods that are implemented by derived class to get access to element and attributes of xml data. There are various things too that gets from this class such as depth of the node of document means, xml documents also the number of attribute in a node.

There is no of derived class of xml reader one of this is xml text reader class. This xml text reader class read xml data. But this class not helps in validating the DTD or you can say schema information.

Another derived class of xml reader is xml validating reader class. This class read xml data and also supports DTD and schema validation.

The class xml text reader class allows fast access to xml data but not support DTD. It is helpful when we do not require reading full document in to memory. We can initialize xml text reader object to read data from xml document and also initialize an xml text reader object to read data from a stream.

I have explained some of the beautiful methods and properties of xml text readers.

Attribute Count: This property helps to get number of attribute in current node.
Depth: To get the depth of current node.
Item: get the value of an attribute as a string.
Value: get text value of current node.

Learn more on Dot Net Interview Questions here

No comments: