<?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>Seems like I overcomplicated that one</title><link>https://www.infopathdev.com:443/forums/thread/37400.aspx</link><pubDate>Tue, 20 Jan 2009 17:06:11 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:37400</guid><dc:creator>ACrush</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/37400.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=37400</wfw:commentRss><description>Apparently just attr.nodeValue = &amp;quot;14&amp;quot; should work.</description></item><item><title>Changing attribute value for an existing element</title><link>https://www.infopathdev.com:443/forums/thread/37399.aspx</link><pubDate>Tue, 20 Jan 2009 16:51:03 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:37399</guid><dc:creator>ACrush</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/37399.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=37399</wfw:commentRss><description>I found some unexpected behaviour while developing my InfoPath 2003 compatible form template with C#. &lt;br /&gt;
The problem is, I cannot change an attribute value on an existing element with the following code:
&lt;br /&gt;&lt;br /&gt;
Initial element&lt;br /&gt;
&amp;lt;my:Employee xmlns:my=&amp;quot;...&amp;quot; my:ID=&amp;quot;&amp;quot; my:FirstName=&amp;quot;Jane&amp;quot; my:LastName=&amp;quot;Doe&amp;quot;&amp;gt;Jane Doe&amp;lt;/my:Employee&amp;gt;
&lt;br /&gt;&lt;br /&gt;

node = thisXDocument.selectSingleNode(&amp;quot;my:Employee&amp;quot;); // OK&lt;br /&gt;
attr = node.attributes.getNamedItem(&amp;quot;my:ID&amp;quot;); // OK&lt;br /&gt;
node.attributes.setNamedItem(attr).nodeValue = &amp;quot;14&amp;quot;; // COM Exception
&lt;br /&gt;&lt;br /&gt;

The debugger shows COM exceptions like E_FAIL or 0x80043001 which are not informative.&lt;br /&gt;
The same code works with temporary elements:
&lt;br /&gt;&lt;br /&gt;

node = thisXDocument.DOM.createNode(&amp;quot;my:Employee&amp;quot;); // OK&lt;br /&gt;
node.attributes.setNamedItem(thisXDocument.DOM.createAttribute(&amp;quot;my:ID&amp;quot;)).nodeValue=&amp;quot;14&amp;quot;; // OK
&lt;br /&gt;&lt;br /&gt;

Result:&lt;br /&gt;
&amp;lt;my:Employee my:ID=&amp;quot;&amp;quot; &amp;gt;&amp;lt;/my:Employee&amp;gt;

Assistance / advice appreciated.</description></item></channel></rss>