// Configure //---------------------------------------------------------------------------------------------------
// The XmlReader class is used for reading Xml files. The following describes the class:
//
// Attributes (attribute ):
// ListBox: set this attribute to obtain the client control to display the content of the file read. (The ListBox control is used here)
// XmlPath: set this attribute to obtain the absolute path of a specified Xml file.
//
// Basilic Using (important reference ):
// System. Xml: This namespace encapsulates common classes for Xml operations. The XmlTextReader class is used in this class.
// XmlTextReader: This class provides the ability to read Xml files. It can verify whether the file format is good. If it is not a formatted Xml file, this class will throw an XmlException exception during reading. You can use
// Some methods are used to read, filter, and obtain the node name and value.
//
// Bool XmlTextReader. Read (): reads the next node in the stream. After reading the last node, call this method again. This method returns false.
// XmlNodeType XmlTextReader. NodeType: Type of the current node returned by this attribute
// XmlNodeType. Element Node
// XmlNodeType. EndElement End Element Node
// The first node of the XmlNodeType. XmlDeclaration document
// XmlNodeType. Text node
// Bool XmlTextReader. HasAttributes: whether the current node has any attribute. true or false is returned.
// String XmlTextReader. Name: returns the Name of the current node.
// String XmlTextReader. Value: returns the Value of the current node.
// String XmlTextReader. LocalName: returns the local name of the current node.
// String XmlTextReader. NamespaceURI: returns the namespace URI of the current node.
// String XmlTextReader. Prefix: returns the Prefix of the current node.
// Bool XmlTextReader. MoveToNextAttribute (): Move to the next attribute of the current node
// Configure //---------------------------------------------------------------------------------------------------
Namespace XMLReading
{
Using System;
Using System. Xml;
Using System. Windows. Forms;
Using System. ComponentModel;
/// <Summary>
/// Xml file Reader
/// </Summary>
Public class XmlReader: IDisposable
{
Private string _ xmlPath;
Private const string _ errMsg = "Error Occurred While Reading ";
Private ListBox _ listBox;
Private XmlTextReader xmlTxtRd;
# Region XmlReader Constructor
Public XmlReader ()
{
This. _ xmlPath = string. Empty;
This. _ listBox = null;
This. xmlTxtRd = null;
}
/// <Summary>
/// Constructor
/// </Summary>
/// <Param name = "_ xmlPath"> absolute path of the xml file </param>