Library tutorials & articles

What's new in System.Xml 2.0

XML Document Stores and Navigators

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.

Comments

  1. 01 Jan 1999 at 00:00

    This thread is for discussions of What's new in System.Xml 2.0.

Leave a comment

Sign in or Join us (it's free).

AddThis

Related discussion

Related podcasts

  • Episode 10: LINQ

    K Scott leads us in a discussion of LINQ, including:

What is it
How introducing LINQ to .NET changed the framework
LINQ Providers
LINQ to XML
LINQ to SQL - how it’s different from EF, tips and tricks, when to use it

Links:

LINQpad
3rd Party LIN...

Related jobs

Events coming up

  • Dec 6

    Developing AJAX Web Applications with Castle Monorail

    London, United Kingdom

    Monorail is the model-view-controller engine of the Castle Project, bringing many of the best ideas of Ruby on Rails to the .NET world. In this talk, David De Florinier and Gojko Adzic show how Monorail makes it easy to develop .NET based AJAX applications, and how to use the Castle Project to build Web 2.0 applications effectively. Come to this session if you are a .NET web developer. Everyone is welcome!