title: MSXML DOM: Add namespace declaration to an existing node in a tree
body: <p><strong>Problem description:</strong> Read an xml file, traverse to a particular node (element), if it does not have a particular namespace declaration, add the required namespace declaration, and write out the file.</p>
  
  <p>I need to do this in C++ using Microsoft's MSXML DOM APIs. The namespaceURI property on IXMLDOMNode COM object is read-only according to this msdn <a href="http://msdn.microsoft.com/en-us/library/ms763813(VS.85).aspx" rel="nofollow noreferrer">reference</a>. Appreciate any workarounds.</p>
  
  <p><strong>Edit</strong>: I spent quite some time on a workaround: Create a new sibling node in the same document with the namespace I need, then move all the child elements of the original node to this new node, then delete the original node. Well, this does not work, because the child nodes are going to keep whatever default namespace they had before.</p>
  
  <p>And then this simple idea hit me and it works but I am not sure if it will bite me in the future: just create an "xmlns" attribute on the element, giving it the desired namespace value! Any comments?</p>