<?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>Re: Managed Code XPathNavigator</title><link>https://www.infopathdev.com:443/forums/thread/15193.aspx</link><pubDate>Tue, 03 Apr 2007 17:28:39 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:15193</guid><dc:creator>Greg Collins</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/15193.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=15193</wfw:commentRss><description>Yes, the nil attribute MUST be removed from a node prior to adding a value. Inserting a value into a node does not automatically remove the nil attribute. Then if you ever clear the value, you will need to set the nil attribute again (if desired) on that node.</description></item><item><title>Re: Managed Code XPathNavigator</title><link>https://www.infopathdev.com:443/forums/thread/15192.aspx</link><pubDate>Tue, 03 Apr 2007 12:04:04 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:15192</guid><dc:creator>BhailDa</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/15192.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=15192</wfw:commentRss><description>From further investigation I found a solution. Simply check the node value before assignment as follows:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        // Insert Date &lt;br /&gt;            DeleteNil(xnNewRow.SelectSingleNode("my:Today", this.NamespaceManager));&lt;br /&gt;            xnNewRow.SelectSingleNode("my:Today", this.NamespaceManager).SetValue(formatDate(DateTime.Now, false));&lt;br /&gt;_____________________________________________        &lt;br /&gt;Routine&lt;br /&gt;_____________________________________________&lt;br /&gt;        #region Utils&lt;br /&gt;        public void DeleteNil(XPathNavigator node)&lt;br /&gt;        {&lt;br /&gt;            if (node.MoveToAttribute("nil", "http://www.w3.org/2001/XMLSchema-instance"))&lt;br /&gt;                node.DeleteSelf();&lt;br /&gt;        }&lt;br /&gt;        #endregion&lt;br /&gt;</description></item><item><title>Re: Managed Code XPathNavigator</title><link>https://www.infopathdev.com:443/forums/thread/15191.aspx</link><pubDate>Mon, 19 Mar 2007 16:54:56 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:15191</guid><dc:creator>Greg Collins</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/15191.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=15191</wfw:commentRss><description>Is the issue that the node is "blank" or the node is "not present" because that is a big difference.&lt;br /&gt;&lt;br /&gt;Blank nodes should not pose any problem to you, and setting their value should work fine. However, null nodes (i.e. not present in the DOM) this is a "by design" issue. You can't set the value of a node that doesn't exist. First you must insert the node, then you can set its value.&lt;br /&gt;&lt;br /&gt;From what you've stated so far, it sounds like you have an optional field or section in the view, that hasn't been inserted yet. If so, again, this is by design. First insert the field/section, then set the value.</description></item><item><title>Managed Code XPathNavigator</title><link>https://www.infopathdev.com:443/forums/thread/13089.aspx</link><pubDate>Sun, 18 Mar 2007 14:47:03 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:13089</guid><dc:creator>BhailDa</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/13089.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=13089</wfw:commentRss><description>I seem to keep getting errors when trying to assign a value to a field within InfoPath. If the field alreday has a value then no problem. but if its empty/null, then cann assign a value although Xpath seems to find it. Thoughts/views.?&lt;br /&gt;&lt;br /&gt;Code:&lt;br /&gt;&lt;br /&gt;   // Create XPathNavigator positioned at the root of the main data &lt;br /&gt;   // source.&lt;br /&gt;   XPathNavigator myNav = this.MainDataSource.CreateNavigator()&lt;br /&gt;&lt;br /&gt;   // Select employee field and set value to username.&lt;br /&gt;   myNav.SelectSingleNode("//my:employee",this.NamespaceManager).&lt;br /&gt;      SetValue(System.Environment.UserName);&lt;br /&gt;</description></item></channel></rss>