The following classes may be used to read XML data.
The XmlUrlResolver class (System.NewXml.XmlUrlResolver) resolves external XML resources needed to correctly parse input, which are named by a URI. It is used by the XmlTextReader to load DTDs, entities, and XDR, XSD, or namespace schemas. It is also used by XslTransform to process "<xsl:include>" elements.
The abstract XmlReader class (System.NewXml.XmlReader) defines methods to input XML documents conforming to the W3C XML 1.0 and Namespaces specifications.
The XmlTextReader class (System.NewXml.XmlTextReader) extends XmlReader. This class obtains XML data in a forward-only manner from a specified stream object, TextReader (System.IO.TextReader) object, or URL that identifies a Web site or local file.
An XmlUrlResolver is used, if one is available, when external DTDs or schemas are required for validation.
XmlTextReader has methods and properties to:
The XmlNode class (System.NewXml.XmlNode) represents a node as defined in the W3C Document Object Model (DOM). DOM level 1, level 2, and Microsoft enhancements are supported. XmlNode encapsulates the structural relationships of nodes.
The XmlNode class deals with concepts such as parent, child, and sibling nodes; and structural operations such as inserting, replacing, and removing nodes.
The XmlDocument class (System.NewXml.XmlDocument) extends XmlNode, and represents a document as defined in the W3C Document Object Model (DOM). DOM level 1, level 2, and Microsoft enhancements are supported. The document exists as a "tree" of nodes.
The XmlDataDocument class (System.NewXml.XmlDataDocument) extends XmlDocument. The XmlDataDocument can be associated with a DataSet in order to optimize storage of and access to structured data within an XML document. This structured data is exposed through the DataSet and may be accessed, bound, and updated through the DataSet without compromising the full fidelity of the source XML. Since the XmlDataDocument derives from the XmlDocument, it can be used anywhere that an XmlDocument can be used. When the user works with data through the XmlDataDocument (as opposed to the DataSet), the user deals with the document as a whole: the nodes of the entire document are present and available for processing and the user can reference several nodes simultaneously.
Methods of this class can create standard XML features such as document type, CDATA, comment, entity reference, processing instruction, and text elements. Microsoft enhancements provide methods to load the document from a stream, file, or XmlReader derived class; or save the document to a stream or file.
Note that an XmlDataDocument class object has a property that returns a DataSet object, and an existing DataSet object can be used in the construction of a new XmlDataDocument. These two objects provide relational and XML representations of the same data. Together, they enable the user to easily go back and forth between XML and relational data.
As part of XSD schema support, the DataSet class supports mappings, which enable the user to explicitly associate some feature of data in the XML representation (for example, an attribute in a tag) to a feature in the relational representation (for example, a field), and vice versa.
XmlDataDocument adds methods and properties to:
The XslTransform class (System.NewXml.XslTransform) implements the W3C XSL Transformations (XSLT) specification. XslTransform can load an XSLT stylesheet using an XmlReader or XmlNavigator object, transform the input data, then write the results using an XmlWriter or stream object. Objects of the XslTransform class are free-threaded and stateless so they can be shared.
The abstract XmlNavigator class (System.NewXml.XmlNavigator) defines an efficient means of examining and editing XML data. The XmlNavigator class also supports XPath expressions, and may be used as an input argument to XslTransform class objects. Data in an XML document may represent many nodes; however, the XmlNavigator uses a cursor-model that only presents one node, the "current node", at any given time.
The XmlNavigator class is an abstract base class. You use the following derived classes to access XmlDocument and XmlDataDocument objects:
Both the DocumentNavigator and DataDocumentNavigator have the following methods and properties to: