DEFINE VARIABLE hChNode AS HANDLE NO-UNDO.
CREATE X-NODEREF hChNode. REPEAT i = 1 TO hParent:NUM-CHILDREN: /* logvar is used for checking if the return value is zero. */ logvar = hParent:GET-CHILD(hChNode, i). IF hChNode:NODE-VALUE > 0 THEN hChNode:NODE-VALUE = hChNode:NODE-VALUE + i. . . . |
. . .
REPEAT i = 1 TO hNode1:NUM-CHILDREN: logvar = hNode1:GET-CHILD(hChNode, i). IF NOT logvar THEN LEAVE. entries = hNode1:ATTRIBUTE-NAMES. REPEAT j = 1 TO NUM-ENTRIES(entries): aname = ENTRY(j, entries). MESSAGE "attrname is " aname "value is " hNode1:GET-ATTRIBUTE(aname). END. END. . . . |
/* i-clone.p */
DEFINE VARIABLE hXref AS HANDLE NO-UNDO. DEFINE VARIABLE hXref1 AS HANDLE NO-UNDO. DEFINE VARIABLE hText AS HANDLE NO-UNDO. DEFINE VARIABLE hText1 AS HANDLE NO-UNDO. DEFINE VARIABLE hClone AS HANDLE NO-UNDO. DEFINE VARIABLE hRoot AS HANDLE NO-UNDO. DEFINE VARIABLE hDoc AS HANDLE NO-UNDO. CREATE X-NODEREF hXref. CREATE X-NODEREF hXref1. CREATE X-NODEREF hText. CREATE X-NODEREF hText1. CREATE X-NODEREF hClone. CREATE X-NODEREF hRoot. CREATE X-DOCUMENT hDoc. hDoc:CREATE-NODE(hRoot,"root","ELEMENT"). hDoc:INSERT-BEFORE(hRoot,?). hDoc:CREATE-NODE(hXref,"customer","ELEMENT"). hDoc:CREATE-NODE(hXref1,"order","ELEMENT"). hDoc:CREATE-NODE(hText,?,"TEXT"). hDoc:CREATE-NODE(hText1,?,"TEXT"). /* Add the two element nodes to the root, each with a text*/ hXref:SET-ATTRIBUTE("id","54"). hXref:SET-ATTRIBUTE("name","Second Skin Scuba"). hRoot:APPEND-CHILD(hXref). hXref:APPEND-CHILD(hText). hXref1:SET-ATTRIBUTE("id","55"). hXref1:SET-ATTRIBUTE("name","Off the Wall"). hRoot:APPEND-CHILD(hXref1). hXref1:APPEND-CHILD(hText1). hText:NODE-VALUE = "hi from customer". hText1:NODE-VALUE = "hi from order". hXref1:CLONE-NODE(hClone,TRUE). hRoot:APPEND-CHILD(hClone). /* Save the file */ hDoc:SAVE("file","clone1.xml"). DELETE OBJECT hXref. DELETE OBJECT hXref1. DELETE OBJECT hText. DELETE OBJECT hText1. DELETE OBJECT hClone. DELETE OBJECT hRoot. DELETE OBJECT hDoc. |