copynode


Purpose
Copy a node.
Synopsis
function copynode(src:xmldoc, s:integer, dst:xmldoc, d:integer, where:integer):integer
Arguments
src 
Document of node to be copied
Number of the node to copy
dst 
Destination document
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:
XML_FIRST 
as the first element of the list where node d is located
XML_LAST 
as the last element of the list where node d is located
XML_NEXT 
after node d
XML_FIRSTCHILD 
as the first child of node d (node d must be an element)
XML_LASTCHILD 
as the last child of node d (node d must be an element)
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
addnode, delnode
Module
mmxml


If you have any comments or suggestions about these pages, please send mail to support@fico.com.

© Copyright 2001-2013 Fair Isaac Corporation. All rights reserved.