[导入]使用Sharepoint的Lists Web Service调用UpdateListItems方法"增/删/改"List Items

Lists.UpdateListItems方法的签名为:
    public XmlNode UpdateListItems (string listName,XmlNode updates);
第一个参数listName为要操作的List的名字, 其实也可以使用该List的GUID值(包括"{}");
关键是第二个参数, 是用CAML定义的XML格式的XmlNode节点, 我使用的一般的格式为:

[导入]使用Sharepoint的Lists Web Service调用UpdateListItems方法"增/删/改"List Items<Batch OnError="Continue" ViewName="">
[导入]使用Sharepoint的Lists Web Service调用UpdateListItems方法"增/删/改"List Items    
<Method ID="" Cmd="New">
[导入]使用Sharepoint的Lists Web Service调用UpdateListItems方法"增/删/改"List Items        
<Field Name="FieldNameOne">FieldValueOne</Field>
[导入]使用Sharepoint的Lists Web Service调用UpdateListItems方法"增/删/改"List Items        
<Field Name="FieldNameTwo">FieldValueTwo</Field>
[导入]使用Sharepoint的Lists Web Service调用UpdateListItems方法"增/删/改"List Items        [导入]使用Sharepoint的Lists Web Service调用UpdateListItems方法"增/删/改"List Items
[导入]使用Sharepoint的Lists Web Service调用UpdateListItems方法"增/删/改"List Items    
</Method>
[导入]使用Sharepoint的Lists Web Service调用UpdateListItems方法"增/删/改"List Items    
<Method ID="" Cmd="Update">
[导入]使用Sharepoint的Lists Web Service调用UpdateListItems方法"增/删/改"List Items        
<Field Name="ID">IDValue</Field>
[导入]使用Sharepoint的Lists Web Service调用UpdateListItems方法"增/删/改"List Items        
<Field Name="FieldNameOne">FieldValueOne</Field>
[导入]使用Sharepoint的Lists Web Service调用UpdateListItems方法"增/删/改"List Items        
<Field Name="FieldNameTwo">FieldValueTwo</Field>
[导入]使用Sharepoint的Lists Web Service调用UpdateListItems方法"增/删/改"List Items        [导入]使用Sharepoint的Lists Web Service调用UpdateListItems方法"增/删/改"List Items
[导入]使用Sharepoint的Lists Web Service调用UpdateListItems方法"增/删/改"List Items    
</Method>
[导入]使用Sharepoint的Lists Web Service调用UpdateListItems方法"增/删/改"List Items    
<Method ID="" Cmd="Delete">
[导入]使用Sharepoint的Lists Web Service调用UpdateListItems方法"增/删/改"List Items        
<Field Name="ID">IDValue</Field>
[导入]使用Sharepoint的Lists Web Service调用UpdateListItems方法"增/删/改"List Items        
<Field Name="FieldNameOne">FieldValueOne</Field>
[导入]使用Sharepoint的Lists Web Service调用UpdateListItems方法"增/删/改"List Items        
<Field Name="FieldNameTwo">FieldValueTwo</Field>
[导入]使用Sharepoint的Lists Web Service调用UpdateListItems方法"增/删/改"List Items        [导入]使用Sharepoint的Lists Web Service调用UpdateListItems方法"增/删/改"List Items
[导入]使用Sharepoint的Lists Web Service调用UpdateListItems方法"增/删/改"List Items    
</Method>
[导入]使用Sharepoint的Lists Web Service调用UpdateListItems方法"增/删/改"List Items    [导入]使用Sharepoint的Lists Web Service调用UpdateListItems方法"增/删/改"List Items
[导入]使用Sharepoint的Lists Web Service调用UpdateListItems方法"增/删/改"List Items
</Batch>


这里有要说明的地方:
一个Batch节点下可以有多个Method节点, 每个Method节点都有一个Cmd属性, 指明是那种操作, 可以为"New", "Update", 或者是"Delete";
每个Method节点下可以有多个Field节点, 这里有个关键点是: New的时候可以不指定, 但是Update和Delete的时候必须指定Name="ID"的Field节点, 否则操作会失败, 其实很容易可以想象出来其中的道理, 这个ID可以观察到, 这里推荐一个工具:SharePoint Manager 2007
[导入]使用Sharepoint的Lists Web Service调用UpdateListItems方法"增/删/改"List Items

[导入]使用Sharepoint的Lists Web Service调用UpdateListItems方法"增/删/改"List Items

mickeysuda 2008-02-15 15:52 发表评论

文章来源:http://www.cnblogs.com/mickeysuda/archive/2008/02/15/1069825.html

转载于:https://www.cnblogs.com/invent/archive/2008/04/12/1150445.html