I found some unexpected behaviour while developing my InfoPath 2003 compatible form template with C#.
The problem is, I cannot change an attribute value on an existing element with the following code:
Initial element
<my:Employee xmlns:my="..." my:ID="" my:FirstName="Jane" my:LastName="Doe">Jane Doe</my:Employee>
node = thisXDocument.selectSingleNode("my:Employee"); // OK
attr = node.attributes.getNamedItem("my:ID"); // OK
node.attributes.setNamedItem(attr).nodeValue = "14"; // COM Exception
The debugger shows COM exceptions like E_FAIL or 0x80043001 which are not informative.
The same code works with temporary elements:
node = thisXDocument.DOM.createNode("my:Employee"); // OK
node.attributes.setNamedItem(thisXDocument.DOM.createAttribute("my:ID")).nodeValue="14"; // OK
Result:
<my:Employee my:ID="" ></my:Employee>
Assistance / advice appreciated.