The XPathDocument2 Class



The XPathDocument2 Class

The previous chapter provided an overview of the improvements to System.Xml 2.0 and the reasons behind them. This chapter and the next two provide code examples and scenarios for using these new classes.

In this chapter we'll look at the XPathDocument2 class, which is based on the existing XPathDocument class in System.Xml 1.x. We will also examine the XPathEditor and XPathChangeNavigator classes that allow you to perform editing within the XPathDocument2 class and view changes that have been made to the document. The XPathDocument2 class is an XML store that can be validated with a W3C XML schema, so we will also be using the new XmlSchemaSet class to validate the updates to the document.

The topics for this chapter are:

  • Using the XPathDocument2 class and its properties and methods

  • Using the XPathEditor class and its properties and methods

  • Using the XPathChangeNavigator class and its properties and methods

We start off with a look at what the XPathDocument2 class can achieve. XPathDocument2 is a duplicate of the existing XPathDocument class, but it has been extended to allow updates and change tracking at a node level. We will first introduce the editing capabilities of the XPathDocument2 before delving into the rest of its functionality.