
88
CHAPTER 4 Leveraging the SharePoint LiStSWeb Service
Create the method using “Delete” as the command and include the ID column in the field
definitions:
string itemID = “3”;
batchElementUpdate.InnerXml = “<Method ID=’1’ Cmd=’Delete’><Field Name=’ID’>” +
itemID + “</Field></Method>”;
WebServiceConsoleApp\Program.CS
The batch element for the delete now looks like the following:
<Batch OnError=\“Continue\“>
<Method ID=\“1\“ Cmd=\“Delete\“>
<Field Name=\“ID\“>3</Field>
</Method>
</Batch>
Use this batch element object along with the list name to update an existing list item using the
UpdateListItems() web method of the Lists web service:
System.Xml.XmlNode ndReturnDelete = listsWS.UpdateListItems(“Custom List”,
batchElementDelete);
Figure4-15 shows the full code listing in Visual Studio. Figure4-16 shows the SharePoint list with
the deleted item (ID=3).
FIGURE415: Deleting a List item code block
105054c04.indd 88 1/10/12 3:34 PM