NullReferenceException:Object reference not set to an instance of an object - InfoPath Dev
in

InfoPath Dev

NullReferenceException:Object reference not set to an instance of an object

Last post 07-20-2014 02:00 AM by Rahul2011. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • 07-20-2014 02:00 AM

    NullReferenceException:Object reference not set to an instance of an object

    I am reading the term store metadata information from /_vti_bin/TaxonomyClientService.asmx?WSDL webservice to fill the infopath dropdown list.But I am getting the "Object reference not set to an instance of an object" error at the "newNode = nav.Clone();" line. Here is my code: XPathNavigator mainNav = this.MainDataSource.CreateNavigator(); cleanupDropdown(mainNav, "/my:myFields/my:Countries"); XPathNavigator termSetNav = this.DataSources["GetCountries"].CreateNavigator(); string xPath = "/dfs:myFields/dfs:dataFields/tns:GetChildTermsInTermSetResponse/tns:GetChildTermsInTermSetResult"; XPathNavigator nodeNav = termSetNav.SelectSingleNode(xPath, this.NamespaceManager); string resultXML = nodeNav.Value.ToString(); XmlDocument termSetXML = new XmlDocument(); termSetXML.LoadXml(resultXML); XmlNodeList terms = termSetXML.GetElementsByTagName("T"); XPathNavigator nav = this.CreateNavigator(). SelectSingleNode("/my:myFields/my:Countries", this.NamespaceManager);// Note: "/my:myFields/my:Countries" => Group Countries foreach (XmlNode term in terms) { XmlNode v = term.SelectSingleNode("LS/TL"); string termValue = v.Attributes["a32"].Value; string termGuid = term.Attributes["a9"].Value; XPathNavigator newNode = null; newNode = nav.Clone(); //Object reference not set to an instance of an object. newNode.SelectSingleNode("/my:myFields/my:Countries/my:Displayname", this.NamespaceManager).SetValue(termValue); newNode.SelectSingleNode("/my:myFields/my:Countries/my:Value", this.NamespaceManager).SetValue(termValue); nav.InsertAfter(newNode); newNode = null; } nav.DeleteSelf(); nav = null;
Page 1 of 1 (1 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.