Пример кода для получения и установки значения поля формы infopath, вы можете попробовать его.
using (var clientContext = new ClientContext("http://sp:12001/"))
{
var web = clientContext.Web;
var myList = web.Lists.GetByTitle("Mydoc2");
var item = myList.GetItemById(6);
XmlDocument xmlItem = new XmlDocument();
//Open XML file and load it into XML document
var _File = item.File;
ClientResult<Stream> clientResult = _File.OpenBinaryStream();
clientContext.Load(_File, F => F.ServerRelativeUrl);
clientContext.ExecuteQuery();
using (var memory = new System.IO.MemoryStream())
{
byte[] buffer = new byte[1024 * 64];
int nread = 0;
while ((nread = clientResult.Value.Read(buffer, 0, buffer.Length)) > 0)
{
memory.Write(buffer, 0, nread);
}
memory.Seek(0, System.IO.SeekOrigin.Begin);
xmlItem.Load(memory);
}
XPathNavigator navItem = xmlItem.CreateNavigator();
//Redefine NameSpaceManager (Generate the NameSpace manager for this item)
navItem.MoveToFollowing(XPathNodeType.Element);
XmlNamespaceManager nsManager = new XmlNamespaceManager(new NameTable());
foreach (var ns in navItem.GetNamespacesInScope(XmlNamespaceScope.All))
{
if (ns.Key == String.Empty)
{
nsManager.AddNamespace("def", ns.Value);
}
else
{
nsManager.AddNamespace(ns.Key, ns.Value);
}
}
//Change your value here….
var node=navItem.SelectSingleNode("/my:myFields/my:field2", nsManager);
node.SetValue("NewValue");
//Save the modified xml into the item
byte[] xmlData = System.Text.Encoding.UTF8.GetBytes(xmlItem.OuterXml);
Stream NewStream = new MemoryStream(xmlData);
Microsoft.SharePoint.Client.File.SaveBinaryDirect(clientContext, _File.ServerRelativeUrl, NewStream, true);
//item.File.SaveBinary(xmlData);
item.Update();
clientContext.ExecuteQuery();
}