Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XQuery: Inserting Nodes

Tags:

xquery

I'm reading in an XML file using XQuery and want to insert several nodes/elements and generate a new XML file. How can I accomplish this?

I've tried using the replace() function, but, it looks like all my XML tags are being stripped when I call doc() to load my document. So calling replace() isn't any good if my XML tags are being removed.

Any help? Are there other technologies I can use?

like image 339
CoolGravatar Avatar asked Sep 06 '25 06:09

CoolGravatar


1 Answers

An extension to the XQuery language allowing updates -- the XQuery Update Facility -- exists to allow documents to be modified.

Inserting a node looks like this:

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

Among other engines, this is supported by BaseX.

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

like image 106
Charles Duffy Avatar answered Sep 07 '25 23:09

Charles Duffy