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
This is "universal" rename node function (ObjectPascal) using MSXML interfaces, works fine and may be usable:
function RenameXMLTag(e: IXMLNode; NewName: WideString): IXMLNode;
var
Doc : IXMLDocument;
NewElem, NParent : IXMLNode;
DNOld, DNNew : IDOMNode;
AC : IXMLNodeList;
i: Integer;
begin
Doc := e.OwnerDocument;
NewElem := Doc.CreateNode(NewName, e.NodeType);
while e.HasChildNodes do
NewElem.DOMNode.AppendChild(e.DOMNode.firstChild);
AC := e.AttributeNodes;
for i := 0 to AC.Count - 1 do
NewElem.Attributes[AC[i].NodeName] := AC[i].NodeValue;
NParent := e.ParentNode;
DNOld := e.DOMNode;
DNNew := NewElem.DOMNode;
NParent.DOMNode.replaceChild(DNNew, DNOld);
Result := NewElem;
end;