I want to do this change
From:
〈aaa〉 bbbbbb 〈/aaa〉
To:
〈bbb〉 bbbbbb 〈/bbb〉
by using MarkLogic, XQuery.
How to do that?
This can be done using xdmp:node-replace()
Refer - xdmp:node-replace
HTH!
The simplest thing to do is often to use xdmp:node-replace . However, this assumes both that the data you wish to modify is already inside a document in the database and that you are not performing any conflicting updates to that document.
When it's not possible to use xdmp:node-replace, your next best option is to modify the document in-memory and then insert the entire document into the database.
The easiest way to modify the document in-memory is to use mem:replace from the XQuery Memory Operations library .
The most performant way to modify a document in memory is to write a recursive descent tree optimized to the structure of that document.
如果该节点不在文档中,则总是存在幼稚的方法:
〈aaa〉 bbbbbb 〈/aaa〉 ! <bbb>{.}</bbb>
XSLT也内置在服务器中。
xquery version "1.0-ml";
xdmp:document-insert("/test1.xml",
<root>
<child1>
<aaa>bbbbbb</aaa>
</child1>
</root>
);
doc("/test1.xml");
xdmp:node-replace(doc("/test1.xml")/root/child1/aaa,<bbb>bbbbbb</bbb>);
doc("/test1.xml");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.