Kako urediti InfoPath XML datoteku u programski Forum knjižnice u sustavu SharePoint 2007

Ispod linije isječak koda je da se ažuriraju rekord InfoPath xml(file)

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

MemoryStream myInStream = Novi MemoryStream(item.File.OpenBinary());
XmlTextReader čitatelj = Novi XmlTextReader(myInStream);

XmlDocument doc = novi XmlDocument();
doc.Load(čitač);

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

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

doc.DocumentElement.SelectSingleNode(“moj:Status”, nameSpaceManager).Unutarnja Tekst = “Spremljeno”;
doc.DocumentElement.SelectSingleNode(“moj:SaveDate”, nameSpaceManager).InnerText = DateTime.Today.ToString();
System.Text.ASCIIEncoding kodiranje = Novi System.Text.ASCIIEncoding();
SPFile newFile = _web.Folders[“SampleFormLib”].Files.Add(item.File.Name.ToString(), (encoding.GetBytes(doc.OuterXml)), pravi);
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

Dopust jedan Odgovor

Možete koristiti te tags HTML

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