Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The Infopath document is just a regular XML file, the structure of which matches the data sources you defined in the Infopath form. </p> <p>You just need to access the file via the SharePoint object model, modify it using standard methods (<a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.aspx" rel="nofollow noreferrer">XmlDocument API</a>) and then write it back to the SharePoint list. You must be careful to preserve the structure and insert valid data or you won't be able to open the form using Infopath.</p> <p>You should really check out a book on SharePoint if you plan to do any serious development. Infopath is also a minefield.</p> <p>Object model usage examples: <a href="http://svengillis.blogspot.com/2007/11/coding-against-sharepoint-object-model.html" rel="nofollow noreferrer">here</a>, <a href="http://www.bizsupportonline.net/blog/2009/03/2-ways-loop-through-infopath-forms-sharepoint-form-library/" rel="nofollow noreferrer">here</a> and <a href="http://www.obacentral.com/en/Learn/Recommended%20Reading/Understanding%20the%20SharePoint%20Object%20Model.pdf" rel="nofollow noreferrer">here</a>. The ridiculously incomplete MSDN reference documentation is <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.aspx" rel="nofollow noreferrer">here</a>.</p> <p><strong>EDIT</strong>: here is some example code. I haven't done SharePoint for a while so I'm not sure this is 100% correct, but it should give you enough to get started:</p> <pre><code>// Open SharePoint site using (SPSite site = new SPSite("http://&lt;SharePoint_Site_URL&gt;")) { using (SPWeb web = site.OpenWeb()) { // Get handle for forms library SPList formsLib = web.Lists["FormsLib"]; if (formsLib != null) { SPListItem itm = formsLib.Items["myform.xml"]; // Open xml and load it into XML document using (Stream s = itm.File.OpenBinary ()) { MemoryStream ms; byte[] xmlData; XmlDocument xml = new XmlDocument (); xml.Load (s); s.Close (); // Do your stuff with xml here ... // Get binary data for new XML xmlData = System.Text.Encoding.UTF8.GetBytes (xml.DocumentElement.OuterXml); ms = new MemoryStream (xmlData); // Write data to sharepoint item itm.File.SaveBinary (ms); ms.Close (); itm.Update (); } } web.Close(); } site.Close(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload