XQuery: insert nodes

I am reading an XML file using XQuery and want to insert some nodes / elements and generate a new XML file. How can i do this?

I tried using the replace () function, but it looks like all my XML tags are removed when I call doc () to load my document. So the call to replace () is not good if my XML tags are removed.

Any help? Are there other technologies that I can use?

+3
source share
4 answers

An extension of the XQuery updateable language — the XQuery update tool — exists to allow document modification.

The node insert is as follows:

insert node <foo>bar</foo>
  into /bar//baz[id='qux']

Among other engines, this is supported by BaseX .

. http://www.w3.org/TR/xquery-update-10/

+4

XQuery Scripting, :

variable $stores := doc("stores.xml")/stores;

insert node element store { 
  element store-number { 4 },
  element state { "CA" }
} into $stores;

$stores

live http://www.zorba-xquery.com/html/demo#vpshT+pVURyQSCEOKrFBrF0jyGY=

+1

replace() , XML .

, , , - . XQuery Wikibook

, XML, eXist, in situ.

0
0

Source: https://habr.com/ru/post/1746926/


All Articles