copynode
copynode |
Purpose
Synopsis
function copynode(src:xmldoc, s:integer, dst:xmldoc, d:integer, where:integer):integer
Arguments
|
src
|
Document of node to be copied
|
||||||||||
|
s
|
Number of the node to copy
|
||||||||||
|
dst
|
Destination document
|
||||||||||
|
d
|
Node number where to attach the new node in the destination document
|
||||||||||
|
where
|
How to attach the copy of the source node to the node
d:
|
Example
The following code extract shows how to move (copy node, then delete original) and edit a node with all its descendants
declarations
DB: xmldoc
APAC, NewPers, Pers: integer
end-declarations
! Retrieve destination region node
APAC:= getnode(DB, "personnelList/region[@id='APAC']")
! Retrieve employee record (node) for 'Lisa'
Pers:=
getnode(DB, "personnelList/region/employee/name[string()='Lisa']/..")
! Employee Lisa moves to Delhi: copy node & delete in original location
NewPers:= copynode(DB, Pers, DB, APAC, XML_LASTCHILD)
delnode(DB, Pers)
! Update the 'address' information
setvalue(DB, getnode(DB, NewPers, "address"), "Delhi")
Further information
This routine copies the node as well as all of its descendants if it is an
element node. Source and destination documents may be the same.
Related topics
Module
