Si të Edit InfoPath XML skedar në Forum Library programuar në SharePoint 2007

Linjat e mëposhtme kodin e copë është për të rinovuar të dhënat xml InfoPath(skedar)

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

MemoryStream myInStream = MemoryStream i ri(item.File.OpenBinary());
Lexues XmlTextReader = XmlTextReader i ri(myInStream);

XmlDocument doc = ri XmlDocument();
doc.Load(lexues);

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

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

doc.DocumentElement.SelectSingleNode(“tim:Gjendje”, nameSpaceManager).Inner Text = “Saved”;
doc.DocumentElement.SelectSingleNode(“tim: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)), i vërtetë);
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

Ju mund të përdorni këto HTML tags

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