Sharepoint CAML 增删改查 List

Lists.UpdateListItems 方法 (websvcLists)

Windows SharePoint Services 3

Adds, deletes, or updates the specified items in a list on the current site.

命名空间: websvcLists
程序集: STSSOAP (在
stssoap.dll 中)

语法


C#

VB

复制

[SoapDocumentMethodAttribute("http://schemas.microsoft.com/sharepoint/soap/UpdateListItems", RequestNamespace="http://schemas.microsoft.com/sharepoint/soap/", ResponseNamespace="http://schemas.microsoft.com/sharepoint/soap/", Use=SoapBindingUse.Literal, ParameterStyle=SoapParameterStyle.Wrapped)]
public XmlNode UpdateListItems (
	string listName,
	XmlNode updates
)

参数

listName

A string that contains the name of the list. It is recommended that you use the list GUID surrounded by curly braces (i.e., "{GUID}"), but you can also use the list display name.

updates

A Batch element that contains one or more methods for adding, modifying, or deleting items and that can be assigned to a System.Xml.XmlNode object.

The following example shows how to modify column values for two specified items.

XML

复制

<Batch OnError="Continue" ListVersion="1"
ViewName="270C0508-A54F-4387-8AD0-49686D685EB2">
   <Method ID="1" Cmd="Update">
      <Field Name="ID">4<Field>
      <Field Name="Field_Name">Value</Field>
   </Method>
   <Method ID="2" Cmd="Update">
      <Field Name="ID" >6</Field>
      <Field Name="Field_Name">Value</Field>
   </Method>
</Batch>

An empty ViewName attribute in the Batch element causes the default view to be used. The ID attribute in each Method element uniquely identifies the specific update so that errors and return values can be properly identified. Each method that is posted contains Field elements that specify the ID of the item and the new field value for the item. The field ID does not correspond to the index of the item in the collection of items for the list.

The following example shows the format for adding a new item that contains both a Date value and a DateTime value.

XML

复制

<Batch OnError="Continue" ListVersion="1"
ViewName="270C0508-A54F-4387-8AD0-49686D685EB2">
   <Method ID="1" Cmd="New">
      <Field Name=‘ID‘>New</Field>
      <Field Name="Title">Value</Field>
      <Field Name="Date_Column">2007-3-25</Field>
      <Field Name="Date_Time_Column">
         2006-1-11T09:15:30Z</Field>
   </Method>
</Batch>

The following example shows how to delete two items.

XML

复制

<Batch OnError="Continue" ListVersion="1"
ViewName="270C0508-A54F-4387-8AD0-49686D685EB2">
   <Method ID="1" Cmd="Delete">
      <Field Name=‘ID‘>2</Field>
   </Method>
   <Method ID="2" Cmd="Delete">
      <Field Name=‘ID‘>8</Field>
   </Method>
</Batch>
注意:

IDs for deleted items are maintained after delete operations. Consequently, the example deletes the second and eighth items in the list, but 2 and 8 are not reassigned as the IDs of other items.

For descriptions of the various formats used for field types that can be passed in this parameter see SPListItem.

The following examples show the methods that can be posted for operations related to document libraries:

  • Create a folder

    XML

    复制

    <Batch OnError="Continue" PreCalc="TRUE"
    ListVersion="0"
    ViewName="{EF2F5A21-0FD0-4654-84ED-112B4F5A48F8}">
       <Method ID="1" Cmd="New">
          <Field Name="ID">New</Field>
          <Field Name="FSObjType">1</Field>
          <Field Name="BaseName">Name</Field>
       </Method>
    </Batch>
    
  • Update a folder

    XML

    复制

    <Batch OnError="Continue" PreCalc="TRUE"
    ListVersion="0"
    ViewName="{EF2F5A21-0FD0-4654-84ED-112B4F5A48F8}">
       <Method ID="1" Cmd="Update">
          <Field Name="ID">3</Field>
          <Field Name="owshiddenversion">1</Field>
          <Field Name="FileRef">
             http://Server/[sites/][Site/]Shared
             Documents/Folder</Field>
          <Field Name="FSObjType">1</Field>
          <Field Name="BaseName">Name</Field>
       </Method>
    </Batch>
    
  • Delete a folder

    XML

    复制

    <Batch OnError="Continue" PreCalc="TRUE"
    ListVersion="0"
    ViewName="{EF2F5A21-0FD0-4654-84ED-112B4F5A48F8}">
       <Method ID="1" Cmd="Delete">
          <Field Name="ID">4</Field>
          <Field Name="FileRef">
             http://Server/[sites/][Site/]Shared
             Documents/Folder</Field>
       </Method>
    </Batch>
    
  • Update documents

    XML

    复制

    <Batch OnError="Continue" PreCalc="TRUE"
    ListVersion="0"
    ViewName="{EF2F5A21-0FD0-4654-84ED-112B4F5A48F8}">
       <Method ID="1" Cmd="Update">
          <Field Name="ID">2</Field>
          <Field Name="owshiddenversion">1</Field>
          <Field Name="FileRef">
             http://Server/[sites/][Site/]Shared
             Documents/File</Field>
          <Field Name="BaseName">Name</Field>
       </Method>
    </Batch>
    
  • Delete documents

    XML

    复制

    <Batch OnError="Continue" PreCalc="TRUE"
    ListVersion="0"
    ViewName="{EF2F5A21-0FD0-4654-84ED-112B4F5A48F8}">
       <Method ID="1" Cmd="Delete">
          <Field Name="ID">3</Field>
          <Field Name="FileRef">
             http://Server/[sites/][Site/]Shared
             Documents/File</Field>
       </Method>
    </Batch>
    

返回值

An XMLDATA fragment in the following form that shows the status of each method block posted through the updates parameter and that can be assigned to a System.Xml.XmlNode object. For items successfully updated, a row fragment is returned with the updated row values.

XML

复制

<Results xmlns="http://schemas.microsoft.com/sharepoint/soap/">
   <Result ID="1,Update">
      <ErrorCode>0x00000000</ErrorCode>
      <z:row ows_ID="4" ows_Title="Title"
         ows_Modified="2003-06-19 20:31:21"
         ows_Created="2003-06-18 10:15:58"
         ows_Author="3;#User1_Display_Name"
         ows_Editor="7;#User2_Display_Name" ows_owshiddenversion="3"
         ows_Attachments="-1"
         ows__ModerationStatus="0" ows_LinkTitleNoMenu="Title"
         ows_LinkTitle="Title"
         ows_SelectTitle="4" ows_Order="400.000000000000"
         ows_GUID="{4962F024-BBA5-4A0B-9EC1-641B731ABFED}"
         ows_DateColumn="2003-09-04 00:00:00"
         ows_NumberColumn="791.00000000000000"
         xmlns:z="#RowsetSchema" />
   </Result>
   <Result ID="2,Update">
      <ErrorCode>0x00000000</ErrorCode>
      <z:row ows_ID="6" ows_Title="Title"
         ows_Modified="2003-06-19 20:31:22"
         ows_Created="2003-06-18 19:07:14"
         ows_Author="2;#User1_Display_Name"
         ows_Editor="6;#User2_Display_Name" ows_owshiddenversion="4"
         ows_Attachments="0" ows__ModerationStatus="0"
         ows_LinkTitleNoMenu="Title"
         ows_LinkTitle="Title" ows_SelectTitle="6"
         ows_Order="600.000000000000"
         ows_GUID="{2E8D2505-98FD-4E3E-BFDA-0C3DEBE483F7}"
         ows_DateColumn="2003-06-23 00:00:00"
         ows_NumberColumn="9001.00000000000000"
         xmlns:z="#RowsetSchema" />
   </Result>
   ...
</Results>

In this example, the ows_Author and ows_Editor attributes pertain to lookup fields to another list in the database, representing the integer IDs of items in the UserInfo table and the actual values contained by these items within the table.

示例


The following code example modifies the values of two different field values within two items in a list on the current site. The example uses an XmlDocument object to create XmlNode objects for parameters.

This example requires that a using (Visual C#) or Imports (Visual Basic) directive be included for the System.Xml namespace.

C#

VB

复制

Web_Reference_Folder.Lists listService = new Web_Reference_Folder.Lists();
listService.Credentials= System.Net.CredentialCache.DefaultCredentials;

string strBatch = "<Method ID=‘1‘ Cmd=‘Update‘>" +
    "<Field Name=‘ID‘>4</Field>" +
    "<Field Name=‘Field_Number‘>999</Field></Method>" +
    "<Method ID=‘2‘ Cmd=‘Update‘><Field Name=‘ID‘ >6</Field>" +
    "<Field Name=‘Field_DateTime‘>
        2003-11-11T09:15:30Z</Field></Method>"; 

XmlDocument xmlDoc = new System.Xml.XmlDocument();

System.Xml.XmlElement elBatch = xmlDoc.CreateElement("Batch");

elBatch.SetAttribute("OnError","Continue");
elBatch.SetAttribute("ListVersion","1");
elBatch.SetAttribute("ViewName",
    "0d7fcacd-1d7c-45bc-bcfc-6d7f7d2eeb40");

elBatch.InnerXml = strBatch;

XmlNode ndReturn = listService.UpdateListItems("List_Name", elBatch);

MessageBox.Show(ndReturn.OuterXml);

另请参阅


&amp;lt;div&amp;gt;&amp;lt;img alt="DCSIMG" id="Img1" width="1" height="1" src="http://m.webtrends.com/dcsmgru7m99k7mqmgrhudo0k8_8c6m/njs.gif?dcsuri=/nojavascript&amp;amp;amp;WT.js=No" /&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;a href="http://www.omniture.com" title="Web Analytics"&amp;gt; &amp;lt;img src="//msstonojsmsdn.112.2o7.net/b/ss/msstonojsmsdn/1/H.20.2--NS/0" height="1" width="1" border="0" /&amp;gt; &amp;lt;/a&amp;gt;

// =scripts.length){delete mtps.injectScripts;return}script=scripts[index];elem=document.createElement("script");elem.className="mtps-injected";elem.async=!1;var isLoaded=!1,timeoutId=0,injectNextFnName="",injectNext=elem.onerror=function(){isLoaded||(isLoaded=!0,inject(scripts,index+1),window.clearTimeout(timeoutId),elem.onload=elem.onerror=elem.onreadystatechange=null,injectNextFnName&&delete mtps[injectNextFnName],elem.removeEventListener&&elem.removeEventListener("load",injectNext,!1))};elem.addEventListener?elem.addEventListener("load",injectNext,!1):elem.readyState==="uninitialized"?elem.onreadystatechange=function(){(this.readyState==="loaded"||this.readyState==="complete")&&injectNext()}:elem.onload=injectNext;script.hasOwnProperty("url")?(timeoutId=window.setTimeout(injectNext,12e4),elem.src=script.url):(injectNextFnName="_injectNextScript_"+index,mtps[injectNextFnName]=injectNext,timeoutId=window.setTimeout(injectNext,2e3),elem.text="try {\n"+script.txt+"\n} finally { MTPS."+injectNextFnName+" && MTPS."+injectNextFnName+"(); }");parent.appendChild(elem)}var mtps=window.MTPS||(window.MTPS={}),parent=document.getElementsByTagName("head")[0];mtps.injectScripts=function(scripts){inject(preload(scripts),0)}})(window,document);
MTPS.injectScripts([
{ txt: "/**/\r\n(window.MTPS || (window.MTPS = {})).cdnDomains || (window.MTPS.cdnDomains = { \r\n\t\"image\": \"http://i.msdn.microsoft.com\", \r\n\t\"js\": \"http://i2.msdn.microsoft.com\", \r\n\t\"css\": \"http://i3.msdn.microsoft.com\", \r\n\t\"xap\": \"http://msdn.microsoft.com\"\r\n});\r\n/**/" },
{ url: "http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.2.min.js" },
{ txt: "//\n var literalNormalizedUrl = \u0027/zh-cn/library/bb249818(l=zh-cn,v=office.12).aspx\u0027;\n var wt_nvr_ru = \u0027WT_NVR_RU\u0027;\n var wt_fpcdom = \u0027.microsoft.com\u0027;\n var wt_domlist = \u0027msdn.microsoft.com\u0027;\n var wt_pathlist = \u0027\u0027;\n var wt_paramlist = \u0027DCSext.mtps_devcenter\u0027;\n var wt_siteid = \u0027MSDN\u0027;\n var gDomain = \u0027m.webtrends.com\u0027;\n var gDcsId = \u0027dcsmgru7m99k7mqmgrhudo0k8_8c6m\u0027;\n var gFpc = \u0027WT_FPC\u0027;\n\n\n\n if (document.cookie.indexOf(gFpc + \"=\") == -1) {\n var wtidJs = document.createElement(\"script\");\n wtidJs.src = \"//\" + gDomain + \"/\" + gDcsId + \"/wtid.js\";\n document.getElementsByTagName(\"head\")[0].appendChild(wtidJs);\n }\n\n\n\n var detectedLocale = \u0027zh-cn\u0027;\n var wtsp = \u0027msdnlib_office\u0027;\n var gTrackEvents = \u00270\u0027;\n/**/" },
{ txt: "/**/\n var omni_guid = \"3d2a52ee-7a0d-4c9c-bf4e-2e2c17a640b8\";\n/**/" },
{ txt: "//\n\n window.appInsightsId = \u002760854590-027a-4ae4-98be-2741a40f355f\u0027;\n //" },
{ url: "http://i2.msdn.microsoft.com/Combined.js?resources=0:Utilities,1:Layout,2:Header,3:FeedbackCounterAsync,1:Rating,2:Footer,0:Topic,4:webtrendsscript,5:omni_rsid_MSDN,0:AppInsightsPerf,6:Toc,1:SearchBox;/Areas/Epx/Content/Scripts:0,/Areas/Epx/Themes/Base/Content:1,/Areas/Centers/Themes/StandardDevCenter/Content:2,/Areas/Epx/Shared/Content:3,/Areas/Global/Content/Webtrends/resources:4,/Areas/Global/Content/Omniture/resources/MSDN:5,/Areas/Library/Content:6\u0026amp;hashKey=6FECEFF0725E63998BB59ED16B89B2E7" },
{ url: "http://i1.services.social.microsoft.com/search/Widgets/SearchBox.jss?boxid=HeaderSearchTextBox\u0026btnid=HeaderSearchButton\u0026brand=Msdn\u0026loc=zh-cn\u0026focusOnInit=false\u0026emptyWatermark=true\u0026searchButtonTooltip=搜索 MSDN" },
{ url: "http://i2.msdn.microsoft.com/Combined.js?resources=0:PrintExportButton,1:NavigationResize;/Areas/Library/Themes/Base/Content:0,/Areas/Library/Content:1\u0026amp;hashKey=72684789A0F98A77C33C1AC3470E9ECF" },
{ txt: "MTPS = window.MTPS || {}; MTPS.LocalizedStrings = window.MTPS.LocalizedStrings || {}; MTPS.LocalizedStrings.ExpandButtonTooltip = \u0027展开\u0027; MTPS.LocalizedStrings.CollapseButtonTooltip = \u0027折叠\u0027; MTPS.LocalizedStrings.EnhancedExpandTooltip = \u0027单击以展开。双击以全部展开。\u0027; MTPS.LocalizedStrings.EnhancedCollapseTooltip = \u0027单击以折叠。双击以全部折叠。\u0027; MTPS.LocalizedStrings.ExpandAllButtonTooltip = \u0027全部展开\u0027; MTPS.LocalizedStrings.CollapseAllButtonTooltip = \u0027全部折叠\u0027;" },
{ url: "http://i2.msdn.microsoft.com/Combined.js?resources=0:LibraryMemberFilter,1:Toc_Fixed,1:CodeSnippet,1:TopicNotInScope,1:CollapsibleArea,1:VersionSelector,1:SurveyBroker;/Areas/Library/Content:0,/Areas/Epx/Content/Scripts:1\u0026amp;hashKey=BA0D41FD888DE12A388DAF9CAC70144D" },
{ txt: "$(document).ready(function() {\n try {\n var token = $(\"#globalRequestVerification input[name=\u0027__RequestVerificationToken\u0027]\").clone();\n $(\"#siteFeedbackForm\").append(token);\n } catch(err) {\n \n }\n });" }
]);
// ]]>

时间: 2024-10-10 10:25:39

Sharepoint CAML 增删改查 List的相关文章

使用Jquery 操作 sharepoint2013文档库(增删改查)

使用Jquery 操作 sharepoint2013文档库(增删改查) [html] view plaincopyprint? //https://xxx.sharepoint.com/AAA/_api/web/GetFolderByServerRelativeUrl('/AAA/SingtelLaunchProcess')/Files //https://xxx.sharepoint.com/AAA/_api/web/GetFolderByServerRelativeUrl('Document

Python 模拟SQL对文件进行增删改查

1 #!/usr/bin/env python 2 # _*_ coding:UTF-8 _*_ 3 # __auth__: Dalhhin 4 # Python 3.5.2,Pycharm 2016.3.2 5 # 2017/05/15 6 7 import sys,os 8 9 def where(dbfile,where_list): #条件是一个list 10 11 def and_or_where(sub_where_list): 12 '''获取and或同时含有and.or关键字的条

【黑马Android】(04)数据库的创建和sql语句增删改查/LinearLayout展示列表数据/ListView的使用和BaseAdater/内容提供者创建

数据库的创建和sql语句增删改查 1. 加载驱动. 2. 连接数据库. 3. 操作数据库. 创建表: create table person( _id integer primary key, name varchar(20), age integer ); 添加: insert into person(name, age) values('lisi', 19); 删除: delete from person where _id = 1; 修改: update person set name =

ssm框架搭建+easyui增删改查实现

闲来无事,看了看别人的博客文档也跟着敲了敲,特地记录下来,方便以后学习: spring版本:4.0.6 mybatis版本:3.2.5 所有jar包打包下载:http://pan.baidu.com/s/1qLEaU 1.项目目录结构 其中,controller包下存放控制层文件,dao下存放各个model类相关的数据库操作接口,entity下放置各种model类,mappers下放置各个dao对应的映射文件,service服务层就不说了,放置各种service接口,impl是其具体实现类. 2

【Android】Sqlite数据库增删改查

Android系统内置一个Sqlite数据库,如果app需要使用Sqlite数据库数据库存储数据,Android会为此app生成一个.db文件.这个数据库在data/data/<package_name>/databases里面,其中<package_name>为该安卓app的工程包名,这个目录必须root后才能看到.在Windows,单机的应用程序,存储数据,基本放到一个文件里面,正如游戏的存档,基本就是把当前的游戏状态存到一个用户很难找到的文件里面.每次存档读档就是一个从这个存

夺命雷公狗---Thinkphp----12之文章的增删改查(图片上传和关联查询)

我们由于表分析的不够完善,所以我们来加多一个tid的字段,到时候主要目的是为了更好的遍历出文章是属于那个分类下的,表如下所示: 那么下一步我们就开始创建一个ArticleController.class.php的控制器,用来管理文章的增删改查操作,所以我们开始第一步来实现文章的添加,我们先来实现他的增加功能: public function add(){ if(IS_POST){ $data['title'] = I('title'); $data['tid'] = I('tid'); $dat

MyBatis增删改查模板

1. 首先,和Spring整合一下 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springfra

用基本数据结构修改后的学生信息管理系统(增删改查)

package com.xt.student.system; //创建学生类存放信息 public class Student {//声明变量private String stuNo; private String stuName; private String gender; private int age; private int score; //对变量进行封装 public String getStuNo() {return stuNo;} public void setStuNo(St

第二周作业__增删改查

html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption