XQuery not only could be used for query operations, rather than we could use it for inserting, deleting or renaming nodes The "insert" statement is used to insert a node into an other one with the following syntax:
insert NODE into [ as [ first | last ] ] TARGET_NODE insert NODE [ after | before ] TARGET_NODE
Inserting a person as a last one:
insert <person id="P3"><information/></person> as last into /persons
The „replace” statement is used to replace one node to a entirely new one with the following syntax:
replace node CSOMÓPONT with NEW_NODE :replacing the whole node replace value of node CSOMÓPONT with NEW_VALUE :replacing only the value
Replacing a person with P1 id to a person with id P2:
replace node /persons/person[@id="P1"] with <person id="P2"></person>
Changing patient P1's name:
replace value of node /persons/person[@id="P1"]/information/personalInformation/name with "Ödön"
The "delete" statement is used to remove nodes:
delete NODE
Deleting all the persons where the SSN is empty:
delete /persons/person[not(information/medicalInformation/SSN)]