I have an XMLType in PL/SQL and I need to rename some of the nodes and some of the values. For example:
<root>
<fields>
<a>foo</a>
<b>bar</b>
</fields>
</root>
I want to turn the above into this:
<root>
<fields>
<a>foo</a>
<c>baz</c>
</fields>
</root>
I know I can update the value like this:
SELECT UpdateXML(my_xml, '/root/fields/b/text()', 'baz')
INTO my_xml_updated
FROM DUAL;
The result is:
<root>
<fields>
<a>foo</a>
<b>baz</b>
</fields>
</root>
But how can I update the node name from <b>
to <c>
(without affecting the contents of the node)?