Kouman Edit InfoPath XML File nan bibliyotèk Forum Pwogramasyon nan charepwen 2007

Anba a liy nan brib kòd se nan mete ajou infopath XML dosye-a(dosye)

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

MemoryStream myInStream = nouvo MemoryStream(item.File.OpenBinary());
XmlTextReader lektè = nouvo XmlTextReader(myInStream);

XmlDocument doc = nouvo XmlDocument();
doc.Load(lektè);

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

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

doc.DocumentElement.SelectSingleNode(“mwen:Ki dènye nouvèl”, nameSpaceManager).Inner Tèks = “Sove”;
doc.DocumentElement.SelectSingleNode(“mwen: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)), vrè);
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

Ou kapab sèvi ak sa yo tags HTML

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