XML • Transform a DiffGram to CAML

Listing 3. Use CAML Batch documents to make multiple updates, inserts, deletes, or all three to SharePoint lists. This CAML statement reverses the update and insert made by Listing 2's DiffGram. Specify the OnError attribute value as Continue to disregard data-consistency errors that might occur during update operations.

<Batch OnError='Continue' ListVersion='1'>
   <Method ID='Items1' Cmd='Update'>
      <Field Name='ID'>1</Field>
      <Field Name='CustomerID'>ALFKI</Field>
      <Field Name='CompanyName'>Alfreds 
         Futterkiste</Field>
      <Field Name='ContactName'>Maria 
         Anders</Field>
      <Field Name='ContactTitle'>Sales 
         Representative</Field>
      <Field Name='Address'>Obere Str. 57</Field>
      <Field Name='City'>Berlin</Field>
      <Field Name='PostalCode'>12209</Field>
      <Field Name='Country'>Germany</Field>
      <Field Name='Phone'>030-0074321</Field>
      <Field Name='Fax'>030-0076545</Field>
   </Method>
   <Method ID='Items2' Cmd='Delete'>
      <Field Name='ID'>108</Field>
   </Method>
</Batch>