What's new in System.Xml 2.0

Page 3 of 4
  1. Page 1
  2. writers
  3. XML Document Stores and Navigators
  4. Working with XML Schemas

XML Document Stores and Navigators

This article was originally published on DNJ Online
DNJ Online
This article was originally published on DNJ Online
DNJ

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.

You might also like...

Comments

About the author

Alex Homer

Alex Homer United Kingdom

Alex spent most of his earlier working life as a technical salesman, and has had a love-hate relationship with computers that goes way back to the Sinclair Z80 and the Oric Atmos. In 1996 he ret...

Interested in writing for us? Find out more.

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“The generation of random numbers is too important to be left to chance.” - Robert R. Coveyou