Version 1.x supports three XML document stores:
the XmlDocument
, XmlDataDocument
and XPathDocument
. Each has different
features, for example the XmlDocument
supports the W3C standards for
XML document management (the XML DOM model), plus useful additional
features that make it easier to access the contents. The
XmlDataDocument is designed to provide a bridge between XML and
relational data by allowing the content to be accessed as a DataSet
instance as well as a standard XML document. The XPathDocument
is a
fast and efficient document store designed to be accessed only using
XPath
methods and the XPathNavigator (although the XPathNavigator
can
be used over any of the three document stores).
In version 2.0, Microsoft has attempted to simplify the model and
remove confusion over which document store to use. The primary XML
document store is now XmlDocument
, which supports both the W3C model
and the use of the XPathNavigator
. However, in addition, many
enhancements have been made to this combination of classes. In
particular, they now provide a read/write cursor-style API for editing
the contents of the document. You can also create XmlReader
and
XmlWriter
instances located at a node in the document, and use them to
read from or write content into the document. Furthermore, the
XmlDocument
and XPathNavigator
combination also supports the reading
and writing of XML as CLR data types.
Other new features in the XmlDocument
class are the ability to
validate the content before and after editing without having to reload
it through a reader instance (as was necessary in version 1.x), and new methods such as ReadSubtree and WriteSubtree that make it easy to move sections of XML between separate documents.
Meanwhile, the XPathDocument
continues as a high performance,
read-only document store that can only be accessed using an
XPathNavigator
- in much the same way as in version 1.x. However, it
has been optimized for XPath queries and XSLT transformations, and
should be chosen where possible if this type of operation is being
carried out.
Comments