delete an instance with xquery

hello there,
i expect to delete an entire document with xquery, but it doesn’t work.
e.g.

update for $q in input()/organisation
where $q/id=1
do(
delete $q
) 

I got the error message:
update results in non-well-formed document;attempt to delete the root element

Any suggestion is welcome,

Thank you in advance

chacha

Hi chacha,

the $q that you want to delete is the root element, i.e. the uppermost element in the document right below the document node. Deleting this would leave the
document empty and thus non-well-formed.

Delete the document node instead, i.e. do delete $q/…

Regards,
Juliane.

Thank u very much :smiley:

Best Regards,

Chacha

You can also use the root() function to get the document node.