Thursday, February 04, 2010

Getting the Field Values of Infopath Form stored in Sharepoint Form Library

//Get the Site
SPSite site= new SPSite(SITE_URL);
SPWeb Web = site.OpenWeb();
SPFile File = Web.GetFile(InfoPathDocUrl);

//Load the file into XML Document
XmlDocument Document = new XmlDocument();
Document.Load(File.OpenBinaryStream());

//Get the Root node and NamespaceManager of the Infopath form
XmlElement root = Document.DocumentElement;
XmlNamespaceManager NamespaceManager = InitNamespaceManager(Document);

//Get the Field values
string Field1Value= root.SelectSingleNode(Field1XPath, NamespaceManager).InnerText;
string Field2Value= root.SelectSingleNode(Field2XPath, NamespaceManager).InnerText;

No comments: