<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.infopathdev.com:443/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Code</title><link>https://www.infopathdev.com:443/forums/45.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>NullReferenceException:Object reference not set to an instance of an object</title><link>https://www.infopathdev.com:443/forums/thread/98391.aspx</link><pubDate>Sun, 20 Jul 2014 09:00:34 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:98391</guid><dc:creator>Rahul2011</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/98391.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=98391</wfw:commentRss><description>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 &amp;quot;Object reference not set to an instance of an object&amp;quot; error at the &amp;quot;newNode = nav.Clone();&amp;quot; line. Here is my code:


XPathNavigator mainNav = this.MainDataSource.CreateNavigator();
cleanupDropdown(mainNav, &amp;quot;/my:myFields/my:Countries&amp;quot;);
XPathNavigator termSetNav = this.DataSources[&amp;quot;GetCountries&amp;quot;].CreateNavigator();
string xPath = &amp;quot;/dfs:myFields/dfs:dataFields/tns:GetChildTermsInTermSetResponse/tns:GetChildTermsInTermSetResult&amp;quot;;
XPathNavigator nodeNav = termSetNav.SelectSingleNode(xPath, this.NamespaceManager);
string resultXML = nodeNav.Value.ToString();
XmlDocument termSetXML = new XmlDocument();
termSetXML.LoadXml(resultXML);
XmlNodeList terms = termSetXML.GetElementsByTagName(&amp;quot;T&amp;quot;);
XPathNavigator nav = this.CreateNavigator().
                SelectSingleNode(&amp;quot;/my:myFields/my:Countries&amp;quot;, this.NamespaceManager);// Note: &amp;quot;/my:myFields/my:Countries&amp;quot; =&amp;gt; Group Countries

foreach (XmlNode term in terms)
 {
 XmlNode v = term.SelectSingleNode(&amp;quot;LS/TL&amp;quot;);
 string termValue = v.Attributes[&amp;quot;a32&amp;quot;].Value;
 string termGuid = term.Attributes[&amp;quot;a9&amp;quot;].Value;

 XPathNavigator newNode = null;
 newNode = nav.Clone(); //Object reference not set to an instance of an object.
 newNode.SelectSingleNode(&amp;quot;/my:myFields/my:Countries/my:Displayname&amp;quot;,
                    this.NamespaceManager).SetValue(termValue);
                newNode.SelectSingleNode(&amp;quot;/my:myFields/my:Countries/my:Value&amp;quot;,
                this.NamespaceManager).SetValue(termValue);
                nav.InsertAfter(newNode);
                newNode = null;             

 }
 nav.DeleteSelf();
 nav = null;</description></item></channel></rss>