[ Team LiB ] Recipe Synchronizing a DataSet with an XML Document Problem You need to work with both a DataSet and its XML representation. Solution Use a synchronized DataSet and XmlDataDocument. The sample code contains two event handlers and one method: | Team LiB Recipe Synchronizing a DataSet with an XML Document Problem You need to work with both a DataSet and its XML representation. Solution Use a synchronized DataSet and XmlDataDocument. The sample code contains two event handlers and one method Go Synchronizes a DataSet and an XmlDataDocument using one of three methods specified by the user. The default view for the Orders table of the DataSet is bound to the data grid on the form and the contents of the XmlDataDocument are displayed in the text box. Clear Clears the contents of the data grid displaying the DataSet and the text box displaying the contents of the XmlDataDocument. FillDataSet This method loads the DataSet with a subset of the Orders and Order Details data from Northwind and creates a relation between the tables. The C code is shown in Example 8-5. Example 8-5. File Namespaces variables and constants using System using using using using using Table name constants private const String ORDERS_TABLE Orders private const String ORDERDETAILS_TABLE OrderDetails Relation name constants private const String ORDERS_ORDERDETAILS_RELATION Orders_OrderDetails_Relation Field name constants private const String ORDERID_FIELD OrderlD private const String XMLFILENAME Project_Directory @ Chapter 08 . . . private void goButton_Click object sender e DataSet ds null XmlDataDocument xmlDoc null if Load DataSet with schema and data. ds FillDataSet true Get the XML document for the DataSet. xmlDoc new XmlDataDocument ds else if Create DataSet with schema but no data. ds FillDataSet false Get the XML document for the DataSet. xmlDoc new XmlDataDocument ds Load the data into the XML document from the XML file. .