<?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: can't insert nil attribute in web based form...</title><link>https://www.infopathdev.com:443/forums/thread/88773.aspx</link><pubDate>Mon, 08 Apr 2013 15:54:01 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:88773</guid><dc:creator>Poolio</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/88773.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=88773</wfw:commentRss><description>&lt;p&gt;Hi there,&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve been battling with passing null values on boolean fields to a web service, and this exchange seemed so promising... but unfortunately I&amp;#39;m still stuck! This is what I&amp;#39;m doing:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Node.SetValue(string.Empty);&lt;br /&gt;Node.MoveToFirstChild();&lt;br /&gt;Node.DeleteSelf();&lt;br /&gt;Node.CreateAttribute(&amp;quot;xsi&amp;quot;, &amp;quot;nil&amp;quot;, System.Xml.Schema.XmlSchema.InstanceNamespace, &amp;quot;true&amp;quot;);&lt;br /&gt;&lt;/em&gt;&lt;br /&gt;In some cases the node had more than one child, but made sure they were all deleted;&lt;br /&gt;For the namespace, I tried explicitly using&amp;nbsp;&amp;quot;&lt;a href="http://www.w3.org/2001/XMLSchema-instance"&gt;http://www.w3.org/2001/XMLSchema-instance&lt;/a&gt;&amp;quot;, using InstanceNamespace as above, and also node.NamespaceName - none made a difference&lt;br /&gt;&lt;br /&gt;Does anybody have any other ideas about what could be stopping this working?&lt;br /&gt;&lt;br /&gt;As a different approach I&amp;#39;ve tried replacing the entire node, e.g. &lt;br /&gt;&lt;br /&gt;&lt;em&gt;Node.ReplaceSelf(string.Format(&amp;quot;&amp;lt;{0} xsi:nil=&amp;#39;true&amp;#39;/&amp;gt;&amp;quot;, Node.Name));&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;But that results in&amp;nbsp;the error &lt;em&gt;&amp;quot;&amp;#39;xsi&amp;#39; is an undeclared prefix&amp;quot;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Starting to lose the will to live, and much to the chagrin of my data and .Net-focused colleagues, considering setting all the web service fields to strings just so InfoPath can handle them... which is not a great story!&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Thanks,&lt;br /&gt;Poolio&lt;/p&gt;</description></item><item><title>Re: can't insert nil attribute in web based form...</title><link>https://www.infopathdev.com:443/forums/thread/59837.aspx</link><pubDate>Tue, 05 Oct 2010 17:35:15 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:59837</guid><dc:creator>vivaladan</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/59837.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=59837</wfw:commentRss><description>Thanks for posting the fix on here. I wonder if you wouldn&amp;#39;t mind elaborating however on why this works. I&amp;#39;ve been trying the obvious:

node.SetValue(string.Empty);
node.CreateAttribute(&amp;quot;xsi&amp;quot;, &amp;quot;nil&amp;quot;, &amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;, &amp;quot;true&amp;quot;);

and getting the schema validation error when running in a browser. Following the example you posted I now try

node.SetValue(string.Empty);
node.MoveToFirstChild();
node.DeleteSelf();
node.CreateAttribute(&amp;quot;xsi&amp;quot;, &amp;quot;nil&amp;quot;, &amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;, &amp;quot;true&amp;quot;);

and this works! I&amp;#39;m trying to figure out why. The MoveToFirstChild selects whitespace as a node. Is this whitespace a side effect of when I originally delete the nil attribute? Is it this whitespace which System.Xml thinks is a node and different to the schema?</description></item><item><title>Re: can't insert nil attribute in web based form...</title><link>https://www.infopathdev.com:443/forums/thread/52348.aspx</link><pubDate>Tue, 02 Mar 2010 17:42:25 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:52348</guid><dc:creator>Hilary Stoupa</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/52348.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=52348</wfw:commentRss><description>&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;This is an extremely late response to this, but I recently ran into this myself.&lt;/p&gt;
&lt;p&gt;After talking to some folks at Microsoft, here is the problem and the solution:&lt;/p&gt;
&lt;blockquote&gt;&lt;span style="COLOR:#1f497d;"&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;Basically, there are differences in the way MSXML (InfoPath client XML library) and System.Xml (IPFS XML library) are validating the XML against the schema. After executing the SetValue() method, System.Xml recognizes the empty text node as a child of the “my:file” node. As such, a validation error occurs when you attempt to reapply the ‘nil’ attribute. The following code will succeed on the client and server:&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR:#1f497d;"&gt;&lt;font size="3" face="Calibri"&gt;&amp;nbsp;&lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR:#1f497d;"&gt;&lt;/span&gt;&lt;span style="COLOR:#1f497d;"&gt;&lt;font size="3" face="Calibri"&gt;&amp;nbsp;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR:#1f497d;"&gt;&lt;/span&gt;&lt;span style="COLOR:#1f497d;"&gt;&lt;font size="3" face="Calibri"&gt;&lt;font face="Courier New"&gt;&lt;span style="FONT-SIZE:10pt;"&gt;XPathNavigator file = MainDataSource.CreateNavigator().SelectSingleNode(&lt;/span&gt;&lt;span style="FONT-SIZE:10pt;"&gt;&lt;font color="#a31515"&gt;&amp;quot;/my:myFields/my:file&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-SIZE:10pt;"&gt;, NamespaceManager);&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR:#1f497d;"&gt;&lt;font size="3" face="Calibri"&gt; &lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR:#1f497d;"&gt;&lt;font size="3" face="Calibri"&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR:#1f497d;"&gt;&lt;font size="3" face="Calibri"&gt;
&lt;div style="MARGIN-TOP:0in;PADDING-LEFT:0in;PADDING-RIGHT:0in;MARGIN-BOTTOM:0pt;FONT-SIZE:11pt;"&gt;&lt;font face="Calibri"&gt;&lt;/font&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style="MARGIN-TOP:0in;PADDING-LEFT:0in;PADDING-RIGHT:0in;MARGIN-BOTTOM:0pt;FONT-SIZE:11pt;"&gt;&lt;font face="Courier New"&gt;&lt;span style="FONT-SIZE:10pt;"&gt;&lt;font color="#0000ff"&gt;if&lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-SIZE:10pt;"&gt; (&lt;/span&gt;&lt;span style="FONT-SIZE:10pt;"&gt;&lt;font color="#0000ff"&gt;null&lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-SIZE:10pt;"&gt; != file &amp;amp;&amp;amp; !file.Value.Equals(&lt;/span&gt;&lt;span style="FONT-SIZE:10pt;"&gt;&lt;font color="#2b91af"&gt;String&lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-SIZE:10pt;"&gt;.Empty))&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div style="MARGIN-TOP:0in;PADDING-LEFT:0in;PADDING-RIGHT:0in;MARGIN-BOTTOM:0pt;FONT-SIZE:11pt;"&gt;&lt;span style="FONT-SIZE:10pt;"&gt;&lt;font face="Courier New"&gt;{&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN-TOP:0in;TEXT-INDENT:0.5in;PADDING-LEFT:0in;PADDING-RIGHT:0in;MARGIN-BOTTOM:0pt;FONT-SIZE:11pt;"&gt;&lt;span style="FONT-SIZE:10pt;"&gt;&lt;font color="#008000" face="Courier New"&gt;//clear node&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN-TOP:0in;TEXT-INDENT:0.5in;PADDING-LEFT:0in;PADDING-RIGHT:0in;MARGIN-BOTTOM:0pt;FONT-SIZE:11pt;"&gt;&lt;span style="FONT-SIZE:10pt;"&gt;&lt;font face="Courier New"&gt;file.MoveToFirstChild();&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN-TOP:0in;TEXT-INDENT:0.5in;PADDING-LEFT:0in;PADDING-RIGHT:0in;MARGIN-BOTTOM:0pt;FONT-SIZE:11pt;"&gt;&lt;span style="FONT-SIZE:10pt;"&gt;&lt;font face="Courier New"&gt;file.DeleteSelf();&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN-TOP:0in;TEXT-INDENT:0.5in;PADDING-LEFT:0in;PADDING-RIGHT:0in;MARGIN-BOTTOM:0pt;FONT-SIZE:11pt;"&gt;&lt;span style="FONT-SIZE:10pt;"&gt;&lt;font color="#008000" face="Courier New"&gt;//add nil attribute&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN-TOP:0in;TEXT-INDENT:0.5in;PADDING-LEFT:0in;PADDING-RIGHT:0in;MARGIN-BOTTOM:0pt;FONT-SIZE:11pt;"&gt;&lt;font face="Courier New"&gt;&lt;span style="FONT-SIZE:10pt;"&gt;file.CreateAttribute(&lt;/span&gt;&lt;span style="FONT-SIZE:10pt;"&gt;&lt;font color="#a31515"&gt;&amp;quot;xsi&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-SIZE:10pt;"&gt;, &lt;/span&gt;&lt;span style="FONT-SIZE:10pt;"&gt;&lt;font color="#a31515"&gt;&amp;quot;nil&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-SIZE:10pt;"&gt;, &lt;/span&gt;&lt;span style="FONT-SIZE:10pt;"&gt;&amp;quot;&lt;a href="http://www.w3.org/2001/XMLSchema-instance" target="_blank"&gt;http://www.w3.org/2001/XMLSchema-instance&lt;/a&gt;&amp;quot;&lt;/span&gt;&lt;span style="FONT-SIZE:10pt;"&gt;, &lt;/span&gt;&lt;span style="FONT-SIZE:10pt;"&gt;&lt;font color="#a31515"&gt;&amp;quot;true&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-SIZE:10pt;"&gt;);&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div style="MARGIN-TOP:0in;PADDING-LEFT:0in;PADDING-RIGHT:0in;MARGIN-BOTTOM:0pt;FONT-SIZE:11pt;"&gt;&lt;font face="Calibri"&gt;&lt;/font&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style="MARGIN-TOP:0in;PADDING-LEFT:0in;PADDING-RIGHT:0in;MARGIN-BOTTOM:0pt;FONT-SIZE:11pt;"&gt;&lt;span style="FONT-SIZE:10pt;"&gt;&lt;font face="Courier New"&gt;}&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;/font&gt;&lt;/span&gt;&lt;/blockquote&gt;</description></item><item><title>can't insert nil attribute in web based form...</title><link>https://www.infopathdev.com:443/forums/thread/32271.aspx</link><pubDate>Tue, 16 Sep 2008 06:03:19 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:32271</guid><dc:creator>StormAttacker</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/32271.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=32271</wfw:commentRss><description>&lt;p&gt;hello everybody, i try to clear&amp;nbsp;double typed field, i&amp;#39;ve used&amp;nbsp;next&amp;nbsp;instructions, &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; if (!node.MoveToAttribute(&amp;quot;nil&amp;quot;, &amp;quot;&amp;quot;))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; node.CreateAttribute(&amp;quot;xsi&amp;quot;, &amp;quot;nil&amp;quot;, node.NamespaceURI, &amp;quot;true&amp;quot;);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; node.SetValue(&amp;quot;&amp;quot;);&lt;/p&gt;
&lt;p&gt;in the client infopath application it works fine, but when form is opened in&amp;nbsp;a web browser it shows me error message:&amp;quot;Schema validation found non-datatype errors.&amp;quot;&lt;/p&gt;
&lt;p&gt;Does anyone know why&amp;nbsp;it happens? thanks. &lt;/p&gt;
&lt;p&gt;ps: InfoPath 2007&amp;nbsp;and c#&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item></channel></rss>