Kif teditja InfoPath Fajl XML fil Librerija Forum programmatically fil SharePoint 2007

L-hawn taħt linji ta 'snippet kodiċi huwa li taġġorna r-rekord xml InfoPath(fajl)

SPWeb _web = SPContext.Current.Web;
SPList _list = _web.Lists[“SampleFormLib”];

MemoryStream myInStream = MemoryStream ġdida(item.File.OpenBinary());
Qarrej XmlTextReader = XmlTextReader ġdida(myInStream);

Doc XmlDocument = XmlDocument ġdida();
doc.Load(qarrej);

reader.Close();
myInStream.Close();

XmlNamespaceManager nameSpaceManager = XmlNamespaceManager ġdida(doc.NameTable);
nameSpaceManager.AddNamespace(“tiegħi”, “http://schemas.microsoft.com/office/infopath/2003/myXSD/2009-06-11T12:44:57“);

doc.DocumentElement.SelectSingleNode(“tiegħi:Status”, nameSpaceManager).Test Inner = “Ssejvjata”;
doc.DocumentElement.SelectSingleNode(“tiegħi:SaveDate”, nameSpaceManager).InnerText = DateTime.Today.ToString();
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
SPFile newFile = _web.Folders[“SampleFormLib”].Files.Add(item.File.Name.ToString(), (encoding.GetBytes(doc.OuterXml)), veru);
item.File.Update();

Make sure you execute item.File.Update() to commit the changes (I got the errors while execute item.Update() and spent couple of hours to find 🙁 )

1 comment to How to Edit InfoPath XML File in Forum Library Programmatically in SharePoint 2007

Leave a Reply

Tista 'tuża dawn it-tags HTML

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>