Let's say we have a doc as:
<node>
<name>Shivangi</name>
<desig>Software Engineer</desig>
</node>
I want it to be changed to:
<node>
<FirstName>Shivangi</FirstName>
<desig>Software Engineer</desig>
</node>
You can replace the name
element with a FirstName
element constructed with the text()
from the original name
, and then use xdmp:node-replace()
:
xquery version "1.0-ml";
let $doc := doc("/test.xml")
let $name := $doc/node/name
return xdmp:node-replace($name, <FirstName>{$name/text()}</FirstName>)