XML•Track Changes With DiffGram

Listing 1. This listing shows a portion of a DataSet stored in DiffGram format. The DiffGram format for a DataSet stores changes so that both the current and the previous versions are available. You can commit, roll back, or examine each change to each table using different DiffGrams.

<?xml version="1.0" standalone="yes"?>
<diffgr:diffgram xmlns:msdata=
   "urn:schemas-microsoft-com:xml-msdata" 
      xmlns:diffgr="
   urn:schemas-microsoft-com:xml-diffgram-v1">
   <EmployeeDataSet xmlns=
   "http://www.tempuri.org/EmployeeDataSet.xsd">
      <Employees diffgr:id="Employees1" 
         msdata:rowOrder="0" 
         diffgr:hasChanges="modified">
         <EmployeeID>1</EmployeeID>
         <LastName>NewName</LastName>
         <FirstName>Nancy</FirstName>
         <Title>Sales Representative</Title>
         <TitleOfCourtesy>Ms.</TitleOfCourtesy>
         <City>Seattle</City>
         <Region>WA</Region>
         <PostalCode>98122</PostalCode>
         <Country>USA</Country>
         <HomePhone>(206) 555-9857</HomePhone>
         <Extension>5467</Extension>
      </Employees>
      <Employees diffgr:id="Employees2" 
         msdata:rowOrder="1">
         <EmployeeID>2</EmployeeID>
         <LastName>Fuller</LastName>
         <FirstName>Andrew</FirstName>
         <Title>Vice President, Sales</Title>
         <TitleOfCourtesy>Dr.</TitleOfCourtesy>
         <City>Tacoma</City>
         <Region>WA</Region>
         <PostalCode>98401</PostalCode>
         <Country>USA</Country>
         <HomePhone>(206) 555-9482</HomePhone>
         <Extension>3457</Extension>
      </Employees>
      <Employees diffgr:id="Employees10" 
         msdata:rowOrder="9" 
         diffgr:hasChanges="inserted">
         <EmployeeID>10</EmployeeID>
         <LastName>New Guy</LastName>
         <FirstName>The</FirstName>
      </Employees>
   </EmployeeDataSet>
   <diffgr:before>
      <Employees diffgr:id="Employees1" 
         msdata:rowOrder="0" 
      xmlns=
      "http://www.tempuri.org/EmployeeDataSet.xsd">
         <EmployeeID>1</EmployeeID>
         <LastName>Davolio</LastName>
         <FirstName>Nancy</FirstName>
         <Title>Sales Representative</Title>
         <TitleOfCourtesy>Ms.</TitleOfCourtesy>
         <City>Seattle</City>
         <Region>WA</Region>
         <PostalCode>98122</PostalCode>
         <Country>USA</Country>
         <HomePhone>(206) 555-9857</HomePhone>
         <Extension>5467</Extension>
      </Employees>
      <Employees diffgr:id="Employees9" 
         msdata:rowOrder="8" 
         xmlns=
      	 "http://www.tempuri.org/EmployeeDataSet.xsd">
         <EmployeeID>9</EmployeeID>
         <LastName>Elmo</LastName>
         <FirstName>Anne</FirstName>
         <Title>Sales Representative</Title>
         <TitleOfCourtesy>Ms.</TitleOfCourtesy>
         <Address>7 Houndstooth Rd.</Address>
         <City>London</City>
         <PostalCode>WG2 7LT</PostalCode>
         <Country>UK</Country>
         <HomePhone>(71) 555-4444</HomePhone>
         <Extension>452</Extension>
      </Employees>
   </diffgr:before>
</diffgr:diffgram>