Hoe Path XML lêer te wysig in Forum Biblioteek programmaties in SharePoint 2007

Die onderstaande reëls van die kode uit is om die Path-xml-rekord by te werk(lêer)

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

MemoryStream myInStream = nuwe MemoryStream(item.File.OpenBinary());
XmlTextReader leser = nuwe XmlTextReader(myInStream);

XmlDocument doc = nuwe XmlDocument();
doc.Load(leser);

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

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

doc.DocumentElement.SelectSingleNode(“my:Status”, nameSpaceManager).Inner text = “Gestoor”;
doc.DocumentElement.SelectSingleNode(“my:SaveDate”, nameSpaceManager).Innerlike Text = DateTime.Today.ToString();
System.Text.ASCIIEncoding encoding = nuwe System.Text.ASCIIEncoding();
SPFile NewFile = _web.Folders[“SampleFormLib”].Files.Add(item.File.Name.ToString(), (encoding.GetBytes(doc.OuterXml)), waar);
item.File.Update();

Maak seker dat jy voer item.File.Update() om die veranderinge te pleeg (Ek het die foute terwyl voer 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

Laat 'n Antwoord

Jy kan gebruik maak hierdie HTML tags

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