Update infopath node value in sharepint document library - InfoPath Dev
in

InfoPath Dev

Update infopath node value in sharepint document library

Last post 08-17-2009 12:58 PM by Hilary Stoupa. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 08-16-2009 07:06 PM

    Update infopath node value in sharepint document library

    Hi all,

    I am trying to update documents in an infopath document library in sharepoint. I got "Object Reference not set to an instance of an object" error when try to retrieve a node value.

    codes listed below, Thanks for the help.

                SPSite l_site = new SPSite(textBox1.Text);
                SPWeb l_web = l_site.OpenWeb();
                SPList l_list = l_web.Lists[textBox2.Text];

                foreach (SPListItem objListItem in l_list.Items)
                {
                    SPFile l_file = objListItem.File;
                    l_file.CheckOut();
                    XmlDocument l_xmlFile = new XmlDocument();
                    l_xmlFile.Load(l_file.OpenBinaryStream());
                    XmlNode l_xmlRootNode = l_xmlFile.DocumentElement;
                    XPathNavigator l_xmlNav = l_xmlFile.CreateNavigator();
                    XmlNamespaceManager l_nsmgr = new XmlNamespaceManager(l_xmlFile.NameTable);
                    l_nsmgr.AddNamespace("my", "http://schemas.microsoft.com/office/infopath/2003/myXSD/2008-08-15T09:27:20");

                    string temp2 = l_xmlNav.SelectSingleNode("/my:myFields/my:Financial/my:test", l_nsmgr).Value;   <--- ERROR HERE, I am sure the XML path is correct
                    l_xmlRootNode.SelectSingleNode("/my:myFields/my:Financial/my:test", l_nsmgr).InnerText = "1";
                    
                    MemoryStream l_msFile = new MemoryStream(Encoding.UTF8.GetBytes(l_xmlFile.OuterXml));
                    l_file.SaveBinary(l_msFile);
                    l_file.CheckIn("System Auto Correction on Go & Get",SPCheckinType.MinorCheckIn);
                }

     Regards, john
  • 08-17-2009 12:58 PM In reply to

    Re: Update infopath node value in sharepint document library

    Hi -- I replied to your other post here.

    Hilary Stoupa

Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.