Search code examples
xmlmsxml

Change NodeName of an XML tag element using MSXML


I'd like to change the tag name of a MSXML XMLDOMElement, but unfortunately the nodeName property is read-only. Is there any straightforward way to do it, or have I to work around by doing some insert/replace and deep copy children?

<xml> ...
    <oldTagName>
      ... sub-elements
    </oldTagName>
<more xml> ...

Should become

<xml> ...
    <newTagName>
      ... sub-elements
    </newTagName>
<more xml> ...

Solution

  • According to Document Object Model you can't rename a node.

    See: http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-1950641247

    renameNode is possible in DOM Level 3 but not in MSXML library