using;
using.Xml;
using.Collections.Generic;
using.Text;
ConsoleDemo
{
Program
{
voidMain(args)
{
try
{
test;
}
catch(Exceptionex)
{
Console.WriteLine(ex.Message);
}
Console.WriteLine("END");
Console.Read;
}
privatevoidtest
{
LabPortal.ListslistService=ConsoleDemo.LabPortal.Lists;
listService.Credentials=.Net.CredentialCache.DefaultCredentials;
strBatch="<MethodID='1'Cmd='New'>"+ //
//ID是Method唯标识如果有多个Method就都列在下面
//Cmd类型有:NewUpdateDelete分别对应增加删除更新
"<FieldName='ID'>New</Field>"+ //
//ID在增加操作时只是个唯标记可以随便指定并不对应到实际
//listitemID但在删除和更新时就必须是实际ID了要靠这个来唯指定条记录
"<FieldName='Title'>Smf</Field>"+
"</Method>";
XmlDocumentxmlDoc=XmlDocument;
XmlElementelBatch=xmlDoc.CreateElement("Batch");
//Batch元素下面这些Attribue是可选
elBatch.SetAttribute("OnError","Continue"); //指定出错后是返回还是继续下步
elBatch.SetAttribute("ListVersion","1"); //指定列表版本
elBatch.SetAttribute("ViewName","654446D3-8E70-4483-B2B6-F87329EAC2D9"); //指定所操作列表视图GUID
elBatch.InnerXml=strBatch;
XmlNodendReturn=listService.UpdateListItems("Contracts",elBatch); //在名为Contracts联系人列表中增加条记录
Console.WriteLine(ndReturn.OuterXml);
}
}
}
最新评论