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).

Alex Homer 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 retire...
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...

Events coming up

  • Nov 18

    15 Minutes of Fame

    Dresher, United States

    This is a yearly tradition. We select 10 of the favorite speakers from monthly meetings, code camps, and hands on labs. Each one does a 15 minute talk on their favorite .NET technology. This is our 10th anniversary so we plan a gala event with special prizes and refreshments.

We'd love to hear what you think! Submit ideas or give us feedback